forked from LeeJim/HowToCookOnMiniprogram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest.js
More file actions
31 lines (29 loc) · 698 Bytes
/
Copy pathrequest.js
File metadata and controls
31 lines (29 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const domain = 'http://dev.africans.cn';
export function post(cmd, data = {}) {
const innerData = {};
if (cmd != 'miniprogram/login') {
innerData.token = wx.getStorageSync('token');
}
return new Promise((resolve, reject) => {
wx.request({
method: 'POST',
url: `${domain}/${cmd}`,
data: {
id: 'wy9HvIHSJfNYikzCR3BZ6R6VwTu4ILykYbnevVNYPBY=',
...innerData,
...data
},
success({ data, statusCode}) {
if (statusCode == 200) {
resolve(data.data);
} else {
reject(data.data)
}
},
fail(err) {
console.log('request fail: ', err);
reject(err)
}
})
})
}