I have a cloud function similar to this:
exports.verifyEmail = functions.https.onCall((data, context) => { // data contains session_id (doc id where otp is stored) and otp
return new Promise((resolve, reject) => {
admin.firestore().collection('verification').doc(data.session_id).get().then(doc => {
if(data.otp === doc.data().otp){
return resolve()
} else {
return reject({message: 'OTP did not match'})
}
}).catch(err => {
return reject({message: err.message})
})
})
})
I read this method on a blog somewhere. Now the problem is, when I put wrong OTP on the client side, it shows error as INTERNAL
rather than showing the error message OTP did not match
. What would be the correct way to send the error message through?
Since the err.message
is returning Internal
, then you need to change the returned error to what you want:
}).catch(err => {
return reject({message: "OTP did not match"})
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.