retry-axios icon indicating copy to clipboard operation
retry-axios copied to clipboard

Include an `isFinalRetry` property

Open broom9 opened this issue 5 years ago • 4 comments

When chain this interceptor with another global interceptor that displays an error message, it would be helpful to easily know if this request is the final retry of rax.

Currently, the logic to determine if the current retry is the final one is kind of complicated because of retries and noResponseRetries

broom9 avatar Feb 02 '20 23:02 broom9

Great idea! If we were to do this, I think I'd do something like a retriesRemaining property.

JustinBeckwith avatar Feb 10 '20 02:02 JustinBeckwith

Cool. I currently copied the whole shouldRetryRequest method out to check if a request is the last retry. If we can simply expose the value of it, it should work, too.

broom9 avatar Feb 10 '20 03:02 broom9

was this feature added?

samislam avatar Mar 15 '24 23:03 samislam

The property name is different, but the currentRetryAttempt, which may be a good substitute. https://github.com/JustinBeckwith/retry-axios/blob/main/src/index.ts#L21

We can access this property from config.raxConfig of axios.

declare module 'axios' {
	export interface AxiosRequestConfig {
		raxConfig?: RetryConfig;
	}
}

yutak23 avatar Mar 24 '24 05:03 yutak23