fix(errorCallback): http_error/network_error也触发errorCallback

This commit is contained in:
ivinwu
2022-07-29 11:02:21 +08:00
parent faeaeaba17
commit d17ec87ae3
4 changed files with 10 additions and 10 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{ {
"name": "we-request", "name": "we-request",
"version": "1.6.2", "version": "1.6.3",
"description": "本工具通过拓展小程序的wx.request让开发者通过简单的配置实现自动管理登录态等功能", "description": "本工具通过拓展小程序的wx.request让开发者通过简单的配置实现自动管理登录态等功能",
"keywords": [ "keywords": [
"登录态", "登录态",

View File

@@ -20,8 +20,8 @@ class ErrorWithData extends Error {
function catchHandler(e: ThrowError, obj: IRequestOption | IUploadFileOption, reject: (reason?: any) => void) { function catchHandler(e: ThrowError, obj: IRequestOption | IUploadFileOption, reject: (reason?: any) => void) {
const { type, res } = e; const { type, res } = e;
// 如果有配置统一错误回调函数,则执行它(仅逻辑错误) // 如果有配置统一错误回调函数,则执行它
if (typeof config.errorCallback === "function" && type === 'logic-error') { if (typeof config.errorCallback === "function") {
config.errorCallback(obj, res); config.errorCallback(obj, res);
} }