nest: Route params decorators bug in ES
Route params decorators not working properly in ES
I’m trying to use @Body decorator, but I’m getting unwanted results:
@Post('/signup')
async signUp (
@Request() req,
@Response() res,
@Body('username') username,
@Body('password') password ) {
console.log(username) //[Function: next]
console.log(password) //undefined
}
Then I tried to send the @Body decorator arguments first, but when printing them I got equivalents to the Request, Response and Next in their respective order.
@Post('/signup')
async signUp (
@Body('username') username,
@Body('password') password,
@Request() req,
@Response() res
) {
console.log(username) //IncomingMessage {......... <- req equivalent
console.log(password) //ServerResponse {...... <- res equivalent
console.log(req) //[Function: next] <- next equivalent
console.log(res) //undefined
}
I think the problem is with the order or obligation of the params
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 16 (8 by maintainers)
Hi @benbayard, @cdiaz,
Unfortunately, babel doesn’t support custom parameters decorators… This is why it’s not working without TypeScript 😞
Hi @cdiaz, Now Nest is compatible with pure JavaScript + Babel now 🙂 You can find examples in the docs.
@kamilmysliwiec I was actually just able to solve the issue I was having by using
target: es6@cdiaz can you check if this works for you?@cojack, i’m afraid there’s no solution. The params decorators are the TypeScript feature.