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

Display type correctly for array if obj passed as an array #1394

Merged
merged 2 commits into from Feb 14, 2023

Conversation

ilyasakin
Copy link
Contributor

If we pass an array instead of an object in the JSON file.
It throws an error like this; Data must be an object. Found object. which makes no sense.

This happens because typeof operator returns 'object' if you pass an array as an operand.

So, we should use Array.isArray to determine whether the passed value is an array instead of using typeof operator. We can use typeof as a fallback.

@typicode
Copy link
Owner

Thank you!

@typicode typicode merged commit e371afd into typicode:master Feb 14, 2023
@striezel
Copy link
Contributor

The merge of this pull request seems to break the CI workflow: https://github.com/typicode/json-server/actions/runs/4170357594/jobs/7219243004

It should probably be adjusted or reverted.

typicode pushed a commit that referenced this pull request Feb 18, 2023
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

Successfully merging this pull request may close these issues.

None yet

3 participants