【发布时间】:2020-08-03 13:26:58
【问题描述】:
我有以下链式承诺。在每一步,我都需要评估返回的值是否不为空。我可以在每个步骤中添加一个 if else 条件,但我想知道是否有更简洁的方法来执行此操作。另外,如果值在任何一步都为空,我该如何跳出链?
axios.post('/api/login', accounts)
.then((response) => {
this.nonce = response.data
return this.nonce
}).then((nonce) => {
let signature = this.signing(nonce)
return signature
}).then((signature) => {
this.verif(signature)
})
.catch((errors) => {
...
})
【问题讨论】:
标签: javascript node.js vue.js