question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Route params decorators bug in ES

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
kamilmysliwieccommented, Jul 5, 2017

Hi @benbayard, @cdiaz,

Unfortunately, babel doesn’t support custom parameters decorators… This is why it’s not working without TypeScript 😞

2reactions
kamilmysliwieccommented, Oct 9, 2017

Hi @cdiaz, Now Nest is compatible with pure JavaScript + Babel now 🙂 You can find examples in the docs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pass Flask route parameters into a decorator - Stack Overflow
I believe you're just missing one thing, which is to actually call require_post_data to produce a decorator function in the update_contact route.
Read more >
Router Guards • Angular - codecraft.tv
There is a bug in Angular version 2.1.0 where the canDeactivate function is not passed the future ActivatedRouteSnapshot or the future RouterStateSnapshot ....
Read more >
Python FastAPI — How the '@app.get(“/”)' Syntax Works
Decorators That Take In Arguments. In Python FastAPI, we use this decorator to create a route to an endpoint: @app.get("/") def function():
Read more >
Untangling Python Decorators | Red's Digressions
First, I defined two functions, func_a and func_b and then func_c takes them as parameters. func_c runs the functions taken as parameters and ......
Read more >
View decorators - Django documentation
Decorator to require that a view only accepts the GET and HEAD methods. These methods are commonly considered “safe” because they should not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found