Skip to content

Commit 422f833

Browse files
committed
fix: 修复当响应状态不是 2xx 时候 FanbookApiErrorrequest response 的值不正确的问题
1 parent e2be7a5 commit 422f833

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/axios.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AxiosRequestHeaders, AxiosResponse, CreateAxiosDefaults } from 'axios'
2-
import axios from 'axios'
2+
import axios, { AxiosError, isAxiosError } from 'axios'
33
import { isPlainObject } from 'is-plain-object'
44
import jsonBigint from 'json-bigint'
55
import { FanbookApiError } from './error'
@@ -80,6 +80,8 @@ export async function wrapResponse<D, T = unknown>(request: Promise<AxiosRespons
8080
response = await request
8181
}
8282
catch (e) {
83+
if (isAxiosError(e))
84+
throw new FanbookApiError(undefined, undefined, e.request, e.response, e)
8385
throw new FanbookApiError(undefined, undefined, undefined, undefined, e)
8486
}
8587
const { data } = response

0 commit comments

Comments
 (0)