A
A
Albert Ushakov2022-04-08 14:47:08
React Native
Albert Ushakov, 2022-04-08 14:47:08

Why is Content-Type not being added to Axios React Native?

create code:

const instance = axios.create({
            baseURL: API_URL,
            timeout: 1000,
            headers: {
                  'Accept': 'application/json',
                  'Access-Control-Allow-Origin': '*',
                  'Content-Type': multipart/form-data,
            }
      });

The request itself:
instance.post('stories/', formData).then(async (response) => {
      try {
        console.log(response);
      } catch (e:) {
        console.log(e)
      }
    }).catch((err) => {
      console.log(err)
    });

1. In the latest version 0.26.1 the problem is with FormData but Content-Type is sent.
2. Rolled back to 0.21.4 and Content-Type stopped being sent.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question