您的位置:首頁技術文章
文章詳情頁

javascript - express 中 promise 處理異常

瀏覽:102日期:2023-09-23 17:09:28

問題描述

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);

問題解答

回答1:

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

等于

catch(next)function next(err){}

你說可以么?

回答2:

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

標簽: JavaScript
相關文章:
国产综合久久一区二区三区