我试图在另一个函数中调用两个函数
公共服务组件
function AddEmail(user) {
return auth.createUserWithEmailAndPassword(user.email,user.password);
//createUsers(user) this way of calling is working, but i don't want to invoke like this...
}
function createUsers(user) {
return db.collection("users").add({
firstName: user.firstName,
lastName: user.lastName,
address: user.address,
phoneNumber: user.phoneNumber,
email: user.email,
role: user.role,
});
}
注册组件
submits(e) {
e.preventDefault();
const { user} = this.state;
commonService.AddEmail(user)
.then(() => {
commonService.createUsers(user)
.then(() =>{//success})
.catch(err=> console.log(err));
})
.catch(err=> console.log(err));
}
被AddEmail执行,但不被执行createUsers。我也尝试通过then方法返回和链接,但仍然无法正常工作,我错过了什么?
慕盖茨4494581
回首忆惘然
白猪掌柜的
相关分类