network/request.js
// Enclosed Ajax request const HTTP = (url,type,parameter) => {return new Promise((resolve,reject) => {wx.request({url:url, parameter); method:type, success:function (res) { resolve(res.data); }, fail:function (err) { reject(err) } }) }) } export {http}
Used in index.wpy
import { http } from '.. /network/request'; http("https://easy-mock.com/mock/5cc66aee7a9a541c744c9c07/example/restful/:id/list","GET").then(function (res) { console.log(res) }).catch(function (err) { });
My WeChat public number: God word first