Search code examples
javascriptaxiosmultipartform-data

Axios multipart/form-data request sent as application/x-www-form-urlencoded


I'm attempting to send a multipart/form-data request from a react application to a backend api. When the request is submitted the Content-Type is application/x-www-form-urlencoded.

enter image description here

I tried a few different things including switching from put to putForm. Which, does change the content-type to multipart/form-data, but doesn't include the boundary which causes the api to reject it.

import axios from "axios";
import getEnvironment from "../constants/environments";

export const register = async (request: FormData) => {
    return axios.put(`${getEnvironment.BaseUri}/email/register`, request);
}

Solution

  • The resolution was that the axios version 1.1.3 had a bug. I upgraded to 1.4.0

    Thank you @Phil for pointing it out!