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",
"version": "0.0.5",
"version": "0.0.6",
"main": "dist/index.js",
"module": "dist/index.js",
"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 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<U = any, V = any> {
}
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;
});