https://github.com/cytle/mp-promisify
小程序接口promise化,async/await水到渠成
https://github.com/cytle/mp-promisify
Last synced: about 1 month ago
JSON representation
小程序接口promise化,async/await水到渠成
- Host: GitHub
- URL: https://github.com/cytle/mp-promisify
- Owner: cytle
- Created: 2018-03-20T03:12:32.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-20T11:31:35.000Z (about 7 years ago)
- Last Synced: 2025-04-12T19:04:02.184Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 51.8 KB
- Stars: 5
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mp-promisify
小程序接口promise化,`async`/`await`水到渠成
## 使用
```js
const promisify = require('mp-promisify');const request = promisify(wx.request);
const setStorage = promisify.keyDataPromisify(wx.setStorage);request({
url: 'foo/1'
}).then((result) => {
console.log("The result of request foo/1", result);
}, (e) => {
console.log("request had error", e);
});setStorage('foo', '123')
.then((result) => {
console.log("The result of setStorage foo", result);
}, (e) => {
console.log("setStorage had error", e);
});
```