Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,22 @@
function createAxiosError(message, config, response, code) {
// axios v0.27.0+ defines AxiosError as constructor
if (typeof axios.AxiosError === "function") {
return axios.AxiosError.from(new Error(message), code, config, null, response);
const responseForError = response ? {
headers: {}, // default empty headers if response is present
...response,
} : response;
return axios.AxiosError.from(new Error(message), code, config, null, responseForError);
}

// handling for axios v0.26.1 and below
const error = new Error(message);
error.isAxiosError = true;
error.config = config;
if (response !== undefined) {
error.response = response;
error.response = {

Check failure on line 173 in src/utils.js

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
headers: {}, // default empty headers
...response,
};
}
if (code !== undefined) {
error.code = code;
Expand Down
Loading