回复 (7)
Y
没人回答么
M
promise.then().then()....catch()
中间任何一个then 出错, reject, 调用catch
L
async series 也可以
async.series([
function(){ ... },
function(){ ... }
]);
Y
@leapon series 具体的实现呢?
K
你这个 checkName 和 checkTel 是异步的吗? 不太可能吧? 只是数据校验的话,validator 可以看下。很多 orm 框架也有带 validation 。可以看看。
L
引用 yiranrucianjing@leapon series 具体的实现呢?
async.series([
function(callback){
userModel.checkName(function(err, id){
if (err) {
callback(err, 'checkName');
} else {
// do your stuff with checkName
callback(null, 'checkName');
}
});
},
function(callback){
userModel.checkTel(function(err, id){
if (err) {
callback(err, 'checkTel');
} else {
// do your stuff with checkTel
callback(null, 'checkTel');
}
}
],
function(err, results){
// results is now ['checkName', 'checkTel'] when no error is raised
});
参与回复
登录后即可参与回复。登录