我的index.js
包含以下代码:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.addMessage = functions.https.onRequest((req, res) => {
const original = req.query.text;
admin.database().ref('/messages').push({original: original}).then(snapshot =>
{
res.redirect(303, snapshot.ref);
});
});
exports.makeUppercase = functions.database.ref('/messages/{pushId}/original').onWrite(event => {
const original = event.data.val();
console.log('Uppercasing', event.params.pushId, original);
const uppercase = original.toUpperCase();
return event.data.ref.parent.child('uppercase').set(uppercase);
});
我正在使用nodejs
终端来使用Firebase。我执行时
>node index.js
我收到了以下错误:
node_modules\firebase-functions\lib\config.js:51 throw new Error('Firebase config variables are not available.
Error: Firebase config variables are not available. Please use the latest version of the Firebase CLI to deploy this function.
at init (D:\firebase\functions\node_modules\firebase-functions\lib\config.js:51:15)
at Object.config (D:\firebase\functions\node_modules\firebase-functions\lib\config.js:29:9)
at Object.<anonymous> (D:\firebase\functions\index.js:6:31)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)