Skip to content

Commit 6e8bc10

Browse files
Pick specifics from Axios response object only
1 parent 67666a1 commit 6e8bc10

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/types.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3217,7 +3217,7 @@ export type APIErrorResponse = {
32173217
export class ErrorFromResponse<T> extends Error {
32183218
public code: number | null;
32193219
public status: number;
3220-
public response: AxiosResponse<T>;
3220+
public response: Pick<AxiosResponse<T>, 'data' | 'status' | 'statusText' | 'headers'>;
32213221

32223222
constructor(
32233223
message: string,
@@ -3227,13 +3227,18 @@ export class ErrorFromResponse<T> extends Error {
32273227
response,
32283228
}: {
32293229
code: ErrorFromResponse<T>['code'];
3230-
response: ErrorFromResponse<T>['response'];
3230+
response: AxiosResponse<T>;
32313231
status: ErrorFromResponse<T>['status'];
32323232
},
32333233
) {
32343234
super(message);
32353235
this.code = code;
3236-
this.response = response;
3236+
this.response = {
3237+
data: response.data,
3238+
status: response.status,
3239+
statusText: response.statusText,
3240+
headers: response.headers,
3241+
};
32373242
this.status = status;
32383243
}
32393244
}

0 commit comments

Comments
 (0)