There's no @Form decorator, so how does the route controller receive x-www-form-urlencoded data and inject it?
Use body-parser and you will have that data in body.
@UseBefore(bodyParser.urlencoded())
handleForm(@Body() form: any) {}
how to receive body as buffer
@19majkel94
@pleerock @NoNameProvided
Should we implement an option for @Body decorator to declare the type of the body-parser method to call before action? It's inconvenient to manually do it with @UseBefore.
@19majkel94 Good idea.
Yeah it鈥檚 a good idea
Umm, @Body doesn't parse urlencoded by default?
Btw, express now has its own bodyparser, so I think we should use that, it's 1 less dep to install.
@BruceHem nope, just json/text:
if (actionMetadata.isBodyUsed) {
if (actionMetadata.isJsonTyped) {
defaultMiddlewares.push(this.loadBodyParser().json(actionMetadata.bodyExtraOptions));
} else {
defaultMiddlewares.push(this.loadBodyParser().text(actionMetadata.bodyExtraOptions));
}
}
Any interest in related PR? Or this is by design?
Any update on above issue? is it fixed? How can I read form url encoded values? Any help on using @UseBefore(bodyParser.urlencoded()) on controller would be helpful.
Also hoping for an update to this, ideally for the @Body() parameter to include form data automatically.
Stale issue message
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Use body-parser and you will have that data in body.