|
|
|
@ -45,6 +45,14 @@ function checkStatus(response) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkBizCode(responseJson){
|
|
|
|
|
if (responseJson.errcode === 0) {
|
|
|
|
|
return responseJson;
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(responseJson.errmsg + ': ' + responseJson.errcode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function fetchText(url) {
|
|
|
|
|
const headerObj = getRequestHeader()
|
|
|
|
|
return fetch(url, {
|
|
|
|
@ -108,6 +116,7 @@ export function postJSON(url, obj) {
|
|
|
|
|
}
|
|
|
|
|
}).then(checkStatus)
|
|
|
|
|
.then(response => response.json())
|
|
|
|
|
.then(checkBizCode)
|
|
|
|
|
.catch(error => {
|
|
|
|
|
throw error
|
|
|
|
|
})
|
|
|
|
|