1
votes

I'm currently looking through the Firebase documentation found here...

https://firebase.google.com/docs/admin/setup

... regarding how to initialise the Admin SDK.

I know the article states adding the Firebase Admin SDK to your SERVER - but how would I add this to my application as I am unsure how to add it to a server.

I have tried simply adding it to my index.js file but the console returns the

`Uncaught ReferenceError: require is not defined`

My code:

var admin = require("firebase-admin");

var serviceAccount = require("/Users/morgannwg/Downloads/<JSON NAME>.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://<URL>.firebaseio.com"
});

Any ideas?

Many thanks,

G

1
Hi George. Could you post the actual code that you have so far? - AL.
Hi AL, I've added the code to the question which i'm using to initialise the admin SDK @AL. - GeorgeBT
Are you adding Firebase Admin to an actual Server, or were you trying to add it in a client application? - AL.
I'm not adding it to a server - Simply because I do not know how to do so. So yes its just to the application which I admit does not seem the right thing to do - GeorgeBT

1 Answers

1
votes

You need to create Node.js server app. Here's an example: https://github.com/firebase/quickstart-nodejs