Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request data type change to string on retry #295

Open
tomerparizer opened this issue Dec 26, 2024 · 0 comments
Open

Request data type change to string on retry #295

tomerparizer opened this issue Dec 26, 2024 · 0 comments

Comments

@tomerparizer
Copy link

Hey

I see a weird behavior happening inside the retry mechanism
Once inside the retry phase the request body change to string instead of JSON
As you can see in the simple example below

const axios = require('axios');
const axiosRetry = require('axios-retry').default;

axios.interceptors.request.use((config) => {
  console.log('in interceptor', config.data, typeof config.data);
  return config;
});

axiosRetry(axios, { retries: 3, retryCondition: () => true });

async function main() {
  try {
    const body = {
      name: 'example',
    };

    const { data } = await axios.post('http://localhost:3030/return500', body);
    console.log('got data', data);
  } catch (e) {
    console.log('got an issue', e.message);
  }
}

main();

The outcome is:

in interceptor { name: 'example' } object
in interceptor {"name":"example"} string
in interceptor {"name":"example"} string
in interceptor {"name":"example"} string
got an issue Request failed with status code 500

Can you please help?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant