我有一个电话号码数组,称为phoneNumberArray,当没有用户出现该号码时,我尝试运行此函数,但出现此错误,我想拒绝该号码并存储在变量中
const user = async(acticityObject) => {
const phoneNumberArray = ['+91555555555','+915585565555'];
const getAuth = async phoneNumber => {
return await auth.getUserByPhoneNumber(phoneNumber).catch(console.log);
};
const userRecord = await Promise.all(phoneNumberArray.map(getAuth));
return;
}
module.exports = {user}
与await
您可以使用普通try/catch
:
const getAuth = async phoneNumber => {
try {
return await auth.getUserByPhoneNumber(phoneNumber);
} catch (err) {
// Handle, e.g.:
// console.log(err);
// if (err === 'auth/user-not-found') { ... }
}
};
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句