useBody with `application/x-www-form-urlencoded`
See original GitHub issueHello, when using useBody
I get a string instead of an object. Something like this field=value&another=value
. Is there an option to make this an object? What I currently do is this:
let body = await useBody(req)
body = Object.fromEntries(new URLSearchParams(body))
thanks
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to send post request with x-www-form-urlencoded body
As you set application/x-www-form-urlencoded as content type so data sent must ... Building off of Navoneel's answer, I like to use StreamEx's EntryStream....
Read more >'x-www-form-urlencoded' or 'form-data' ? Explained in 2 mins.
For x-www-form-urlencoded , use bodyParser, which will parse payload into req.body in the format of { key, value } .
Read more >Difference Between form-data, x-www-form-urlencoded and ...
In this tutorial, we'll explore the differences between using form-data, x-www-form-urlencoded, and raw for our request body.
Read more >POST - HTTP - MDN Web Docs
The HTTP POST method sends data to the server. The type of the body of the request is indicated by the Content-Type header....
Read more >How to send x-www-form-urlencoded body?
Hi, Instead of JSON, how to send the data in the body by x-www-form-urlencoded? I mean the format is: name=maggie instead of.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Have confirmed that the current solution causes data loss.
When you submit this form:
await readBody(event)
returns this dataThe expected data should be something like:
This can be accomplished with the
qs
package:@pi0
As @walmartwarlord said, you already released this feature as a part of v0.5.3.
https://github.com/unjs/h3/blob/v0.5.3/CHANGELOG.md#053-2022-03-31
So you could close this issue, or are there any remaining issues in your mind?