I'm following along with this talk from google. However I can't instantiate a firebase object.
I have a package.json
file and started with:
npm install firebase --save
Then did the following:
let Firebase = require('firebase');
let myFire = new Firebase('[link to my app]');
However, when I run the johhny-five
app from terminal, I get the error: Firebase is not a function
.
How am I supposed to intstantiate the object? Did Firebase change their API?
Note: I injected it into the repl and running >> typeof Firebase I get that it's actually an 'object'.
Yes, they changed the API, take a look: Upgrade your Web / Node.js app from Firebase.com.
This is how you do it now:
// See https://firebase.google.com/docs/web/setup#project_setup for how to
// auto-generate this config
var config = {
apiKey: "apiKey",
authDomain: "projectId.firebaseapp.com",
databaseURL: "https://databaseName.firebaseio.com"
};
firebase.initializeApp(config);
var rootRef = firebase.database().ref();
To get the config
values, go to the URL at the top of the previous code, Add Firebase to your Web Project, which guides you to do the following:
To add Firebase to your app, you'll need a Firebase project and a short snippet of code to add to your application HTML that has a few details about your project.
- Create a Firebase project in the Firebase console, if you don't already have one.
- If you already have an existing Google project associated with your app, click Import Google Project. Otherwise, click Create New Project.
- If you already have a project, click Add App from the project overview page.
- Click Add Firebase to your web app.
- Click Copy, then paste the code snippet into your application HTML.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments