perf: request.js;

main
Lei OT 4 months ago
parent d6bf52c3ba
commit 5c32c721ae

@ -47,11 +47,14 @@ function checkStatus(response) {
}
function checkBizCode(responseJson) {
if (responseJson && Object.prototype.hasOwnProperty.call(responseJson, 'errcode')) {
if (responseJson.errcode === 0) {
return responseJson;
} else {
throw new Error(responseJson.errmsg + ': ' + responseJson.errcode);
}
}
return responseJson;
}
export function fetchText(url) {
@ -64,7 +67,6 @@ export function fetchText(url) {
}
}).then(checkStatus)
.then(response => response.text())
.then(checkBizCode)
.catch(error => {
throw error
})
@ -150,7 +152,6 @@ export function postStream(url, obj) {
}
}).then(checkStatus)
.then(response => response.json())
.then(checkBizCode)
.catch(error => {
throw error
})

Loading…
Cancel
Save