request 处理errcode

feature/price_manager
Lei OT 1 year ago
parent 49f8cafade
commit bff8a1ea78

@ -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
})

Loading…
Cancel
Save