本文介绍了ReferenceError:在云函数中未定义firebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Firebase的新手,但是当我部署函数并执行onWrite()
方法时,这是我得到的错误:
I am new to firebase but when I deploy my functions and execute onWrite()
method this is the error I get:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendPaymentNotification = functions.database.ref('payments/{paymentID}').onWrite(event => {
if (event.data.previous.exists()) {
return;
}
firebase.database().ref('payments').child(event.params.paymentID).once('value').then(function(snap){
var jobData = snap.val();
console.log(jobData)
});
});
推荐答案
适用于任何使用此功能的人.您应该使用"admin"而不是火力基地".
For anyone googling that. You should use "admin" instead of "firebase".
这篇关于ReferenceError:在云函数中未定义firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!