ReferenceError:在云函数中未定义firebase

编程入门 行业动态 更新时间:2024-10-21 11:38:25
本文介绍了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:

ReferenceError:firebase未定义 在exports.sendJobNotification.functions.database.ref.onWrite.event上 (/user_code/index.js:11:3) 在/user_code/node_modules/firebase-functions/lib/cloud-functions.js:35:20 在process._tickDomainCallback(internal/process/next_tick.js:135:7)

ReferenceError: firebase is not defined at exports.sendJobNotification.functions.database.ref.onWrite.event (/user_code/index.js:11:3) at /user_code/node_modules/firebase-functions/lib/cloud-functions.js:35:20 at process._tickDomainCallback (internal/process/next_tick.js:135:7)

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

本文发布于:2023-11-28 06:57:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641380.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   中未   定义   ReferenceError   firebase

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!