parse params and
See original GitHub issueis there a way to specify that Params and Query be injected as a number instead of a string?
@Get("validate/:code?")
codes(@Param("code") code : number) {
return ValidationService.validate(number); // error: currently gets passed as a string
}
I know I can use parseInt(code)
but i am wondering if there is a more elegant way of specifying to the injector to return the param as a number.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How do I parse a URL query parameters, in Javascript?
2 Answers 2 · 7. Each item should be url decoded using decodeURIComponent() · 2. Both the parameter name and value must be...
Read more >Free Online Url Parser / Query String Splitter
This free online tool lets you parse complex urls into parts and splits the query string into a readable format.
Read more >How to Get URL Parameters with JavaScript - SitePoint
In this article, we'll show you how to parse and manipulate URL parameters using JavaScript. Getting a URL Parameter. In modern browsers, this ......
Read more >Don't ever write your own function to parse URL parameters
Don't ever write your own function to parse URL parameters. A line of code that reads `parse('foo=bar');. Published on Apr 11, 2021 by...
Read more >Dynamically Parse URL Query String Parameters into an ...
Dynamically Parse URL Query String Parameters into an Object with JavaScript Code ... We do our best to ensure that the code in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
Since the directory structure of the repository has changed, these are the new links:
Usage example https://github.com/nestjs/nest/blob/master/sample/01-cats-app/src/cats/cats.controller.ts Pipe (which is already integrated into Nest.js) https://github.com/nestjs/nest/blob/master/sample/01-cats-app/src/common/pipes/parse-int.pipe.ts
Hello @jaufgang, That’s why we have param-scoped pipes. Usage example https://github.com/nestjs/nest/blob/master/examples/01-cats-app/src/modules/cats/cats.controller.ts Pipe https://github.com/nestjs/nest/blob/master/examples/01-cats-app/src/modules/common/pipes/parse-int.pipe.ts