I have configured axios-retry in my nodejs application as per https://www.npmjs.com/package/axios-retry
Following is my code
import axios from 'axios';
import axiosRetry from 'axios-retry';
export class RetryRoute {
public async testRetry(
req: express.Request,
res: express.Response,
next: express.NextFunction,
): Promise<any> {
const client = axios.create({ baseURL: `http://www.test.com/` });
axiosRetry(axios, { retries: 3 });
client.get('/error')
.then(result => {
this.logger.info('success', result);
result.data;
}).catch(error => {
console.log('error', error.message);
error !== undefined
});
}
}
console.log('error', error.message);. prints as expected. which means call is failed with code 404 as expected. But next call from retry not happening.
You need to specify retry condition, below code retry for every failed request