Showing
1 changed file
with
6 additions
and
6 deletions
| @@ -12,14 +12,14 @@ const MAIN_URL = 'https://devpay.brae.co'; | @@ -12,14 +12,14 @@ const MAIN_URL = 'https://devpay.brae.co'; | ||
| 12 | * @param {function} errCB 失败回调函数 | 12 | * @param {function} errCB 失败回调函数 |
| 13 | * @param {Object} header 补充包头 | 13 | * @param {Object} header 补充包头 |
| 14 | */ | 14 | */ |
| 15 | -export default function post(url, data, sucCB, errCB, header = {}) { | 15 | +export default function (url, data, sucCB, errCB, header = {}) { |
| 16 | const requestUrl = `${MAIN_URL}${url}`; | 16 | const requestUrl = `${MAIN_URL}${url}`; |
| 17 | const body = JSON.stringify(data); | 17 | const body = JSON.stringify(data); |
| 18 | const headers = { | 18 | const headers = { |
| 19 | - "Accept": "application/json", | 19 | + 'Accept': 'application/json', |
| 20 | - "Content-Type": "application/json", | 20 | + 'Content-Type': 'application/json', |
| 21 | ...header, | 21 | ...header, |
| 22 | - } | 22 | + }; |
| 23 | fetch(requestUrl, { | 23 | fetch(requestUrl, { |
| 24 | method: 'POST', | 24 | method: 'POST', |
| 25 | body: body, | 25 | body: body, |
| @@ -37,12 +37,12 @@ export default function post(url, data, sucCB, errCB, header = {}) { | @@ -37,12 +37,12 @@ export default function post(url, data, sucCB, errCB, header = {}) { | ||
| 37 | errCB(res); | 37 | errCB(res); |
| 38 | } | 38 | } |
| 39 | }).catch(err => { | 39 | }).catch(err => { |
| 40 | - console.log(err) | 40 | + console.log(err); |
| 41 | // 所有非 200 的情况都作为服务器内部错误处理 | 41 | // 所有非 200 的情况都作为服务器内部错误处理 |
| 42 | if (err.message === 'server') { | 42 | if (err.message === 'server') { |
| 43 | errCB({ code: 500, enmsg: 'server error', cnmsg: '服务器内部错误', data: null }); | 43 | errCB({ code: 500, enmsg: 'server error', cnmsg: '服务器内部错误', data: null }); |
| 44 | } else { | 44 | } else { |
| 45 | errCB({ code: 500, enmsg: 'client error', cnmsg: '网络异常', data: null }); | 45 | errCB({ code: 500, enmsg: 'client error', cnmsg: '网络异常', data: null }); |
| 46 | } | 46 | } |
| 47 | - }) | 47 | + }); |
| 48 | } | 48 | } |
-
Please register or login to post a comment