Description of the issue
I am working on a nextjs project. The problem is when I am posting multiple images array via postForm is not working but if I use postForm.append then those image arrays are working properly.
axios version : "1.6.1",
This is an example of posting via Axios postForm
const images = [File, File, File]
const res = await axios.postForm("/example",images)
This is Example of posting old process
const postForm = new FormData();
images.forEach((img) => {
postFrom.append("images", img);
});
How to solve this problem.
Here's how you can modify your code to use
axios.post
andFormData
:Make sure to use
axios.post
instead ofaxios.postForm
. Also, ensure that you set the correctContent-Type
header for theFormData
object, as shown in the above snippet.