Skip to content

How to using req.urlencoded to read form body and return as a json data ? #182

Answered by kartikk221
muamarhm asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, Request.urlencoded() only supports urlencoded bodies. For example: "key1=value1&key2=value2".

In your case, you are trying to send what seems like multipart FormData. There is a multipart parser in hyper-express for form file uploading which can be used with Request.multipart() see docs for proper usage.

If the above does not work for some reason, you always have the option to do Request.text() to get the body as a raw string and then use any NPM package like https://www.npmjs.com/package/parse-multipart-data to parse it.

Hope the above helps!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kartikk221
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