如何查看Promise的当前状态?

时间:2015-07-21 08:49:48

标签: javascript promise es6-promise

如果承诺已经解决,我需要检查调试目的 - 类似p.isResolved()。反正有吗?

1 个答案:

答案 0 :(得分:4)

解析时触发日志,或者如果希望在其他地方处理事件则发出事件:

triggerMyPromiseMethod()
    .then((response) => {
        console.log('Promise resolved', response)

        // continue...
    })
    .catch((err) => {
        console.log('Something went wrong with my Promise', err)
    })
相关问题