Skip to content

Commit

Permalink
fix: Fix potential exception when there is no response
Browse files Browse the repository at this point in the history
Not sure it can happen in real life, but be on the safe side.
  • Loading branch information
orgads committed Jun 13, 2024
1 parent 1401ac7 commit d79646f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ async function onError(instance: AxiosInstance, error: AxiosError) {
const onBackoffPromise = new Promise((resolve, reject) => {
let delay = 0;
// If enabled, check for 'Retry-After' header in response to use as delay
if (config.checkRetryAfter && axiosError.response?.headers['retry-after']) {
if (
config.checkRetryAfter &&
axiosError.response?.headers?.['retry-after']
) {
const retryAfter = parseRetryAfter(
axiosError.response.headers['retry-after'] as string,
);
Expand Down

0 comments on commit d79646f

Please sign in to comment.