【发布时间】:2017-08-25 12:20:17
【问题描述】:
我正在尝试使用给定的电子邮件和密码列表通过循环 (JS) 将 100 名用户注册到 firebase。
但其中很少有已经存在,而且很少有电子邮件格式错误。因此,如果用户电子邮件已注册或格式错误,我编写的脚本会抛出异常。我想跳过该用户的注册并继续下一个。
如果发生异常,如何跳过循环。
for (var i = 0; i < data.length; i++){
//Variables of email and password
if (email !== '' && email !== undefined) {
const promise = firebase.auth().createUserWithEmailAndPassword(email, password)
.then(function(response) {
console.log(response.uid);
});
promise.catch(function(e){
console.log(e.message);
//Skip and continue to next iteration
});
}
}
【问题讨论】:
标签: javascript firebase firebase-authentication