file upload using Axios in React
08:15 08 Feb 2022

I am uploading a file in React using Axios. When I am doing

alert(values.attachedFile[0]);, it displays:

but when I am sending values.attachedFile[0] in an Axios post request, an empty object is being sent.

const { result } = await axios.post(app.resourceServerUrl + '/file/upload', {
    data: values.attachedFile[0],
    headers: {
        'Content-Type': 'multipart/form-data',
    },
});

You can see the request data being empty:

enter image description here

What is my mistake?

javascript reactjs axios nestjs