May 21, 2021 WeChat Mini Program Development Document
Extending WeChat's small program api supports promise
npm install --save miniprogram-api-promise
The profileall is called .js at the applet portal (app) and only once.
Example:
import { promisifyAll, promisify } from 'miniprogram-api-promise';
const wxp = {}
// promisify all wx's api
promisifyAll(wx, wxp)
console.log(wxp.getSystemInfoSync())
wxp.getSystemInfo().then(console.log)
wxp.showModal().then(wxp.openSetting())
// compatible usage
wxp.getSystemInfo({success(res) {console.log(res)}})
// promisify single api
promisify(wx.getSystemInfo)().then(console.log)