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

FormData not work #277

Open
DokiDoki1103 opened this issue Jun 19, 2024 · 1 comment
Open

FormData not work #277

DokiDoki1103 opened this issue Jun 19, 2024 · 1 comment

Comments

@DokiDoki1103
Copy link

DokiDoki1103 commented Jun 19, 2024

If the first request of using form data fails, I need to retry, but the second retry will definitely get stuck and no new request will be sent. It is suspected that the stream has been read and cannot be reused

After trying again, it will get stuck and error timeouts will occur one after another

import axiosRetry from "axios-retry";
import axios from "axios";
import FormData from 'form-data'

const form = new FormData()
form.append('my_field', 'my_value');


const instance = axios.create({
    headers: form.getHeaders(),
    maxContentLength: Infinity,
});


axiosRetry(instance, {
    retries: 3, 
    retryCondition(error) {
        console.log("retrying")
        return true
    }
});


instance.post('http://example.com/submit-form', form)
    .then((response) => {
        console.log('Success:', response.data);
    })
    .catch((error) => {
        console.error('Error:', error);
    });
@yutak23
Copy link
Contributor

yutak23 commented Jul 24, 2024

i think POST should not retry.

Also refer to #281.

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

2 participants