I am trying to setup firebase JS client with NodeJS. So far here is my code
var firebase = require('firebase/app');
require('firebase/database');
var config = {
apiKey: "MY_SECRET_KEY_fhcWICPI",
authDomain: "my_fir_app.firebaseapp.com",
databaseURL: "https://my_fir_app.firebaseio.com",
};
var firApp = firebase.initializeApp(config);
firebase.database.enableLogging(true)
// Get a reference to the database service
var database = firebase.database();
Then here is one of my Firebase functions to save data to the real time database.
/**
* This will save the authors of stories in Firebase
* @param {String} id The ID of the author
* @param {String} firstName The authors first name
* @param {String} lastName The authors last name
* @param {Timestamp} dateCreated The unix time stamp when the author was created
*/
function saveStoryAuthor(id, firstName, lastName, dateCreated) {
database.ref('mystoriesdb/authors/' + id).set({
first_name: firstName,
last_name: lastName,
date_created : dateCreated
});
}
Finally, somewhere in the middle of my code am calling this function as
...
saveStoryAuthor('MZ8XWXNrkG', 'Dennis', 'Richie')
...
However, this is what I get in the logs (since I have enabled logging)
$ node index.js
p:0: Browser went online.
p:0: Making a connection attempt
getToken() completed. Creating connection.
c:0:0: Connection created
p:0: Failed to get token: Error: No transports available
p:0: data client disconnected
p:0: Trying to reconnect in 326.9669258513522ms
0: onDisconnectEvents
p:0: Making a connection attempt
getToken() completed. Creating connection.
c:0:1: Connection created
p:0: Failed to get token: Error: No transports available
I am probably doing something wrong. Could someone help.
via nmvictor
No comments:
Post a Comment