From 81afd2965ee8190b2ec4b751dcc939c109ccfccc Mon Sep 17 00:00:00 2001 From: xion Date: Sun, 29 Sep 2024 01:04:54 +0800 Subject: [PATCH] fix: response error --- package.json | 2 +- src/index.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d6b59e5..486ec3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/query", - "version": "0.0.5", + "version": "0.0.6", "main": "dist/index.js", "module": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 0ec6c15..8b74d5a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -64,6 +64,7 @@ export class Query { const headers = { ...this.headers, ...options?.headers }; const adapter = options?.adapter || this.adapter; const beforeRequest = options?.beforeRequest || this.beforeRequest; + const afterResponse = options?.afterResponse || this.afterResponse; const timeout = options?.timeout || this.timeout; const req = { url: url, @@ -76,8 +77,8 @@ export class Query { } return adapter(req).then(async (res) => { res.success = res.code === 200; - if (options?.afterResponse) { - return await options.afterResponse(res); + if (afterResponse) { + return await afterResponse(res); } return res; });