Skip to content

Is possible send empty array by FormData? #5577

Discussion options

You must be logged in to vote

An empty array can't be represented in FormData as this is a flat data structure that only emulates data nesting, but you can send JSON string as a field value.

await axios.postForm("http://localhost/", {
  emptyArr: JSON.stringify([])
});

Unfortunately, at the moment server frameworks (like multer) do not support automatic deserialization as there is no established practice of serializing JSON into FormData fields, so you need to do it manually

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by wildfrontend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants