这是我的代码
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
const accountSid = "***";
const authToken = "***";
const client = require('twilio')(accountSid, authToken);
var db = admin.database();
var ref = db.ref("history");
exports.sendSMSNotfication = functions.database.ref('issue/{id}').onCreate(async (snapshot,context) =>{
const val=snapshot.val();
return admin.database().ref('owners').on('value',function(snapshot){
snapshot.forEach(function (childSnapshot){
var data=childSnapshot.val();
client.messages
.create({
body: '\nAlert\nSmartLampPole '+val.Id+' is facing an issue\nReported as '+val.Description+'.',
from: '+147*******5',
to: data.Contact
}).then(message => console.log(message.sid));
})
});
});
exports.addHistory = functions.database.ref('issue/{id}').onCreate(async (snapshot, context) => {
const val = snapshot.val();
const timeElapsed = Date.now();
const today = new Date(timeElapsed);
var datetime=today.toUTCString();
return admin.database().ref('history').push().set({
Lamp: val.lampid,
Reported: datetime,
Completed:"",
Status:"Pending",
AssignedTo:"",
Issue:val.errormsg
});
});
exports.addKeyofHistory=functions.database.ref('history/{id}').onCreate(async (snapshot,context) =>{
const val=snapshot.val();
const id=snapshot.key;
return admin.database().ref('issue').child(val.Lamp).update({
HistoryId: id
});
});
当我部署它时,我遇到了部署失败
但我过去部署过,但不知道是什么问题
控制台显示
+ functions: functions folder uploaded successfully
i functions: updating Node.js 12 function sendSMSNotfication(us-central1)...
i functions: updating Node.js 12 function addHistory(us-central1)...
i functions: updating Node.js 12 function addKeyofHistory(us-central1)...
Functions deploy had errors with the following functions:
sendSMSNotfication(us-central1)
addHistory(us-central1)
addKeyofHistory(us-central1)
To try redeploying those functions, run:
firebase deploy --only "functions:sendSMSNotfication,functions:addHistory,functions:addKeyofHistory"
To continue deploying other features (such as database), run:
firebase deploy --except functions
登录 firebase 说
{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":3,"message":"Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation."},"authenticationInfo":{"principalEmail":"mymail@gmail.com"},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"projects/project-code/locations/us-central1/functions/sendSMSNotfication"}
请问谁能找到原因 这段代码以前确实部署过,但我现在部署失败了,我没有对代码进行太多更改