fix: response error
Some checks failed
Publish to npm / publish (push) Has been cancelled

This commit is contained in:
熊潇 2024-09-29 01:04:54 +08:00
parent fe5b3ec15b
commit 81afd2965e
2 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@kevisual/query", "name": "@kevisual/query",
"version": "0.0.5", "version": "0.0.6",
"main": "dist/index.js", "main": "dist/index.js",
"module": "dist/index.js", "module": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@ -64,6 +64,7 @@ export class Query<U = any, V = any> {
const headers = { ...this.headers, ...options?.headers }; const headers = { ...this.headers, ...options?.headers };
const adapter = options?.adapter || this.adapter; const adapter = options?.adapter || this.adapter;
const beforeRequest = options?.beforeRequest || this.beforeRequest; const beforeRequest = options?.beforeRequest || this.beforeRequest;
const afterResponse = options?.afterResponse || this.afterResponse;
const timeout = options?.timeout || this.timeout; const timeout = options?.timeout || this.timeout;
const req = { const req = {
url: url, url: url,
@ -76,8 +77,8 @@ export class Query<U = any, V = any> {
} }
return adapter(req).then(async (res) => { return adapter(req).then(async (res) => {
res.success = res.code === 200; res.success = res.code === 200;
if (options?.afterResponse) { if (afterResponse) {
return await options.afterResponse(res); return await afterResponse(res);
} }
return res; return res;
}); });