1

I am using firebase first time and stucked on it for 2 days. looked several example like on stackoverflow, but nothing works.

my firebase version is 3.4.2.

     pushData(){

    var Firebase = require("firebase");
    var ref = new Firebase(" https://differentdatara.firebaseio.com");
    var usersRef = ref.child("fish1");
    usersRef.set({
        alanisawesome: {
            date_of_birth: "June 23, 1912",
            full_name: "Alan Turing"
        },
        gracehop: {
            date_of_birth: "December 9, 1906",
            full_name: "Grace Hopper"
        }
    });

}

When ever i am running code it gives me "Firebase is not a constructor".

also tried with componentWillMount but nothing works. I try like this

     componentWillMount(){
    console.log('yesdoneit');
    var Firebase = require("firebase");
    this.FirebaseRef = new Firebase(" https://passwordsaves-11b33.firebaseio.com");
       }
2
  • I'm not much of a JS person (yet), but typically for something like new <something>, that <something> needs to be a type. You are using a variable. Doesn't the Firebase object instead have a method you should use? Commented Aug 3, 2016 at 9:29
  • i can't use that stuff because i am writting my code in jsx file format and working on react boiler plate Commented Aug 3, 2016 at 9:31

1 Answer 1

4

As it is written here:

In the new SDKs, you no longer instantiate a database references via new Firebase. Instead, you will initialize the SDK via firebase.initializeApp():

BEFORE

var ref = new Firebase("https://databaseName.firebaseio.com");

AFTER:

var config = {
  apiKey: "apiKey",
  authDomain: "projectId.firebaseapp.com",
  databaseURL: "https://databaseName.firebaseio.com"
};

firebase.initializeApp(config);

var rootRef = firebase.database().ref();

Since, your firebase version is 3.4.2, you have to do it like in after section.

Sign up to request clarification or add additional context in comments.

3 Comments

i just know my database url.. nothing else... can you help me in finding AuthSomain and apikey
I am a little busy now, I'll try to help you in some time.
hey can please you tell me, how to push the data with this version..?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.