[英]Cannot initialize Firebase admin sdk in Cloud Functions
I am trying to create a Firebase Cloud Function that uses the firebase admin SDK.我正在尝试创建一个 Firebase 云 Function 使用 firebase 管理员 ZF20E3C5E604C0AB3D6FAZDAZ。 However, when I deploy the function below and attempt the function I receive the error "INTERNAL".但是,当我在下面部署 function 并尝试 function 时,我收到错误“内部”。 In the logs on the Firebase dashboard I am seeing:在 Firebase 仪表板的日志中,我看到:
Unhandled error TypeError: admin.auth.updateUser is not a function
What am I missing?我错过了什么? Thanks in advance.提前致谢。
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp()
exports.updateUser = functions.https.onCall((data, context) => {
admin.auth
.updateUser({
email: data.email,
displayName: data.name,
emailVerified: true
})
.then(userRecord => userRecord.uid)
.catch(err => {
throw new functions.https.HttpsError('unknown', err)
})
})
This is how I am calling it on my client:这就是我在我的客户端上调用它的方式:
const updateUser = functions.httpsCallable('updateUser')
updateUser({
name: this.state.name,
email: this.state.email,
track: this.state.track,
password: this.state.password
})
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
The correct syntax is admin.auth().updateUser(...
with parentheses after auth
.正确的语法是admin.auth().updateUser(...
在auth
后面加上括号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.