Reputation: 3
I am trying to create a Firebase Cloud Function that uses the firebase admin SDK. However, when I deploy the function below and attempt the function I receive the error "INTERNAL". In the logs on the Firebase dashboard I am seeing:
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)
})
Upvotes: 0
Views: 229
Reputation: 598728
The correct syntax is admin.auth().updateUser(...
with parentheses after auth
.
Upvotes: 1