Use async/await
for wechat mini program projects
original creator
npm i wehcat-regenerator-runtime
const regeneratorRuntime = require('wehcat-regenerator-runtime');
const wf = require('wefetch');
// es6 write
async onload () {
let res = await wf.get('/get')
if (res) {
// do something....
}
}
// Es5 write
onload: async function () {
let res = await wf.get('/get')
console.log(res)
// do something....
}