Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error responses #352

Closed
netsi1964 opened this issue Sep 1, 2016 · 3 comments
Closed

Error responses #352

netsi1964 opened this issue Sep 1, 2016 · 3 comments

Comments

@netsi1964
Copy link

If I do say:

http://localhost:3000/posts?q=serve&q=comment

The case here has two q parameters, which confuses the search routine.
It should take only the first parameter or respond with a JSON based error (?).

I get an error text like this:

TypeError: q.toLowerCase is not a function at list (/usr/local/lib/node_modules/json-server/src/server/router/plural.js:89:13) at Layer.handle [as handle_request] (/usr/local/lib/node_modules/json-server/node_modules/express/lib/router/layer.js:95:5) at next (/usr/local/lib/node_modules/json-server/node_modules/express/lib/router/route.js:131:13) at Route.dispatch (/usr/local/lib/node_modules/json-server/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/usr/local/lib/node_modules/json-server/node_modules/express/lib/router/layer.js:95:5) at /usr/local/lib/node_modules/json-server/node_modules/express/lib/router/index.js:277:22 at Function.process_params (/usr/local/lib/node_modules/json-server/node_modules/express/lib/router/index.js:330:12) at next (/usr/local/lib/node_modules/json-server/node_modules/express/lib/router/index.js:271:10) at Function.handle (/usr/local/lib/node_modules/json-server/node_modules/express/lib/router/index.js:176:3) at router (/usr/local/lib/node_modules/json-server/node_modules/express/lib/router/index.js:46:12)

could be better if it had some JSON error :-)

@typicode
Copy link
Owner

typicode commented Sep 2, 2016

I agree, good point :)
We should just take one query param and ignore others if there are duplicates.

@jacobwardio
Copy link
Contributor

I'd like to pick this up if it is available?

To clarify expected behaviour:

Given the client is making a valid request to an endpoint.
When multiple q parameters are passed in the request.
Then only the first is evaluated and subsequent ones are ignored.

Is that correct?

jacobwardio added a commit to jacobwardio/json-server that referenced this issue Feb 5, 2017
jacobwardio added a commit to jacobwardio/json-server that referenced this issue Feb 5, 2017
@typicode
Copy link
Owner

typicode commented Feb 6, 2017

Yes, thanks a lot for the PR 👍

@typicode typicode closed this as completed Feb 6, 2017
jacobwardio added a commit to jacobwardio/json-server that referenced this issue Jul 5, 2017
…rams-error

Fix duplicate query params error (Issue: typicode#352)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants