FormData object is not easy to use so in the example above I already "re-write" it to object structure where I can potentially convert it into JSON (through JSON.stringify(object)). Unfortunately, that's not the end of the story if you have to deal with multi-select values but with a little tweak in the forEach callback it can be managed.
So -> FormData unless you already keep the state somewhere 🤷♂️
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It depends, if I use a framework (say React) I'd just use the state to retrieve the data and don't bother about anything.
In Vanilla solution I'd go for FormData:
FormData object is not easy to use so in the example above I already "re-write" it to object structure where I can potentially convert it into JSON (through
JSON.stringify(object)
). Unfortunately, that's not the end of the story if you have to deal with multi-select values but with a little tweak in theforEach
callback it can be managed.So -> FormData unless you already keep the state somewhere 🤷♂️