Error when requesting route with params and query
See original GitHub issueDescribe the bug
The server hangs itself when I try to send a GET request to a route where I use req.params
and req.query
e.g./cats/:catId/moods?food=fish
To Reproduce
I prepared a small repo to reproduce that error.
git clone https://github.com/fabianmoronzirfas/tinyhttp-request-error.git
npm ci
npm run dev
In another session
curl --request GET \
--url 'http://localhost:3000/cats/1/moods?food=fish'
Expected behavior
I expect the console to log
console.log(req.query);
console.log(req.params);
and to return a response.
res.json({ message: "add a query string", url: req.url });
Versions
node
: v14.13.1@tinyhttp/app
: 0.5.6
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Passing query parameter in nodejs but route is giving error
When you pass id as query parameters, it won't be able to match the path and hence you are receiving an error Can't...
Read more >Return 400 if required query parameter is missing #251 - GitHub
If method and path in request match some route but don't contain mandatory query parameters I would expect a 400 error response rather...
Read more >Error "Invalid value for query parameter" and failed to send a ...
CAUSE. This is because the request being sent is not in the correct format where there's a limitation for maxLength defined in the...
Read more >Routing - hapi.dev
There are two query parameters here, name=ferris and location=chicago . In hapi, you can access query parameters by the request.query object. server.route({ ...
Read more >FromQuery in rocket::request - Rust
pub trait FromQuery<'q>: Sized { type Error; fn from_query(query: ... For example, the parameter user is a trailing query parameter in the following...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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
@talentlessguy
I’ve put up a pull request to add @fabianmoronzirfas! 🎉
Spotted the bug, it hangs in here:
https://github.com/talentlessguy/tinyhttp/blob/master/packages/app/src/app.ts#L215
and to be more concise, here:
https://github.com/talentlessguy/tinyhttp/blob/66bd0d1bbd854cff8bfcf6d3b9ab9ef25d663a26/packages/url/src/index.ts#L5
gonna fix asap
thx for reporting!