Skip to content

Commit

Permalink
fix: 修复当响应状态不是 2xx 时候 FanbookApiErrorrequest response 的值不正确的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikaibenkai committed Aug 16, 2024
1 parent e2be7a5 commit 422f833
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/axios.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AxiosRequestHeaders, AxiosResponse, CreateAxiosDefaults } from 'axios'
import axios from 'axios'
import axios, { AxiosError, isAxiosError } from 'axios'
import { isPlainObject } from 'is-plain-object'
import jsonBigint from 'json-bigint'
import { FanbookApiError } from './error'
Expand Down Expand Up @@ -80,6 +80,8 @@ export async function wrapResponse<D, T = unknown>(request: Promise<AxiosRespons
response = await request
}
catch (e) {
if (isAxiosError(e))
throw new FanbookApiError(undefined, undefined, e.request, e.response, e)
throw new FanbookApiError(undefined, undefined, undefined, undefined, e)
}
const { data } = response
Expand Down

0 comments on commit 422f833

Please sign in to comment.