我尝试在firebase函数上发布简单代码,但每次都会生成错误
errors
functions: Finished running predeploy script.
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (53.73 KB) for uploading
✔ functions: functions folder uploaded successfully
i functions: updating function sendNotification...
⚠ functions[sendNotification]: Deployment error.
Error setting up the execution environment for your function. Please
try again after a few minutes.
Functions deploy had errors. To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
我尝试部署的代码是
'use strict'
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendNotification = functions.database.ref('/notifications/{user_id}/{notification_id}').onWrite(event => {
const user_id = event.params.user_id;
const notification_id = event.params.notification_id;
console.log('We have a notification from : ', user_id);
});
面对此错误大约2天尝试在堆栈和其他论坛上提供所有答案,但能够找到任何人都可以帮助我的解决方案
答案 0 :(得分:0)
你应该让你的函数返回值,null或promise。除此之外,我没有看到任何错误。您似乎得到的错误可能是您身边的连接问题,或者(很奇怪)Google Firebase端的问题。
还尝试更新您的firebase工具
npm install -g firebase-tools
啊,请考虑此更新,以进行一些小的更改,因为云功能不再处于测试阶段: https://firebase.googleblog.com/2018/04/launching-cloud-functions-for-firebase-1-0.html?utm_source=email&utm_medium=email&utm_campaign=cloud_functions_v1.0