How to retry using axios-retry for POST request on 5XX error

315 Views Asked by At

Here is my implementation-

import axiosRetry from 'Axios-retry'

axiosRetry(axios, { retries: 3 });

axios.post('http://localhost:3005/post',{name: "abc"}) // The first request fails and the second returns 'ok'
  .then(result => {
    result.data; // 'ok'
  });

But retry doesn't work because POST is a Idempotent request, So how can I retry POST method using axios-retry for 5XX?

0

There are 0 best solutions below