zhaobinglong / myBlog

https://zhaobinglong.github.io/myBlog/
MIT License
7 stars 0 forks source link

nodejs中各种异步逻辑的优雅写法 #79

Open zhaobinglong opened 3 years ago

zhaobinglong commented 3 years ago

promises

promises的核心方法是then(),我们从then()方法中获取原来回调产生的返回值,或者抛出的异常(拒绝执行的理由)。then()方法有两个可选的参数onFulfilled(执行)和onRejected(拒绝),主要思路: