diff --git a/src/utils/request.js b/src/utils/request.js index fbaf923..7b19198 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -47,11 +47,14 @@ function checkStatus(response) { } function checkBizCode(responseJson) { - if (responseJson.errcode === 0) { - return responseJson; - } else { - throw new Error(responseJson.errmsg + ': ' + responseJson.errcode); + 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 })