From 5c32c721aeca7be609e3db6571e929afb09f8b81 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 26 Dec 2025 14:25:52 +0800 Subject: [PATCH] perf: request.js; --- src/utils/request.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 })