Error parsing triggers: Cannot find module 'firebase-admin'
npm list -g --depth=0
/Users/TDK/.nvm/versions/node/v6.11.2/lib
├── child_process@1.0.2
├── firebase-admin@5.3.0
├── firebase-tools@3.12.0
├── fs@0.0.2
├── npm@5.4.2
└── request@2.83.0
const functions = require('firebase-functions');
const admin = require('firebase-admin');
npm ERR! Cannot read property '0' of undefined
--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/8df59ae5-c022-4e11-bbeb-39065235895b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/8df59ae5-c022-4e11-bbeb-39065235895b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
functions: HTTP Error: 400, Change of function trigger type or event provider is not allowed
firebase.auth().onAuthStateChanged(function(user) { // this runs on login
if (user) { // user is signed in
console.log("User signed in!");
$scope.authData = user;
firebase.database().ref('userLoginEvent').update({'user': user.uid}); // update Firebase database to trigger Cloud Function to get a new IBM Watson token
} // end if user is signed in
else { // User is signed out
console.log("User signed out.");
}
}); // end onAuthStateChanged
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.getWatsonToken = functions.database.ref('/userLoginEvent').onUpdate(event => { // authentication trigger when user logs in
console.log("Executing Firebase function!");
console.log(event.data.val());
var request = require('request');
var fs = require('fs');
var username = 'groucho',
password = 'swordfish',
url = 'https://' + username + ':' + password + '@stream.watsonplatform.net/authorization/api/v1/token?url=https://stream.watsonplatform.net/speech-to-text/api';
request({url: url}, function (error, response, body) {
var tokenService = "app.value('watsonToken','" + body + "');";
fs.writeFile('../public/javascript/services/watsonTokenValue.js', tokenService, (err) => {
if (err) throw err;
console.log('The file has been saved!');
}); // close fs.writeFile
}); // close request
}); // close getWatsonToken
exports.getWatsonToken = functions.database.ref('/userLoginEvent').onUpdate(event => {
Everything is working! Thanks!
--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/97979724-e009-44d8-951e-30792e6b1592%40googlegroups.com.