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

TypeError: Cannot read property 'toString' of null #510

Closed
robvenn opened this issue Apr 6, 2017 · 3 comments
Closed

TypeError: Cannot read property 'toString' of null #510

robvenn opened this issue Apr 6, 2017 · 3 comments

Comments

@robvenn
Copy link

robvenn commented Apr 6, 2017

When trying to add a query parameter with an operator like "?createdAt_like=1491402693000" and the JSON data contains null values, this error is thrown in node_modules/json-server/lib/server/router/plural.js:122:64. Any of those elementValue.toString() calls could throw if they are tested against null.

I also noticed there is probably no way to use _like or _ne with null as value because there's no way to distinguish it from the string "null".

@typicode
Copy link
Owner

Hi @robinvenneman,

Thank you for raising this issue. I've added a test and fix.
It should be available in JSON Server next release.

You're right about "null", maybe a new operator would solve that ?title_is_null&body_is_null.

@robvenn
Copy link
Author

robvenn commented Apr 13, 2017

Cool, thanks @typicode.

A new operator could be useful. I've forked this for a client project to match their API and customised the query params by using JSON with operators, which allows to distinguish strings from other values like false or null... might be another idea for a future version.

@sasikumardr
Copy link

Hi @typicode Just wanted to check with you about updates on this changes? I believe this has not yer added to json-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants