这是在Firebase云功能中返回ES6承诺的正确方法吗?

我具有类似于此功能的云功能:

select count (*) from table_name;

我在某处的博客上阅读了此方法。现在的问题是,当我在客户端放置错误的OTP时,它将错误显示为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}) }) }) }) ,而不是显示错误消息INTERNAL。通过错误消息发送错误消息的正确方法是什么?

wangdahan 回答:这是在Firebase云功能中返回ES6承诺的正确方法吗?

由于err.message返回Internal,因此您需要将返回的错误更改为所需的错误:

}).catch(err => {
      return reject({message: "OTP did not match"})
    })
本文链接:https://www.f2er.com/2922582.html

大家都在问