Front-end time someone asked me how to connect to the background of the mini program, so I directly posted the code here
In
// api request request(url, params) { return new Promise((resolve, reject) => { ({ url: baseUrl + url, method: 'POST', data: params, success(res) { () resolve() }, fail(res) { (res) reject(res) } }) }) }, // api getHomeLayout(params) { return ('/wechat/home/getHomeLayout', params) },
Here baseUrl is the name of your native ip + your background project
Go to the page where you need to call the API, and instantiate the var app = getApp(); use app. getHomeLayout and pass in the specified parameters.