express 中 promise 处理异常

sms_code(userInfo).then(function(data){
    return res.json(data);
})
.then(function(data){
    return res.json(data);
})
.catch(next);

为什么

catch(function(err){
    next(err)
})

可以缩写成

.catch(next);
阅读 2.4k
2 个回答
catch(function(err){
    next(err)
})

等于

catch(next)

function next(err){

}

你说可以么?

setTimeout(function(){
    doSomeSth()
},1000)

setTimeout(doSomeSth,1000);

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题