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

Can't to use "id" as a string in the case that it looks like a natural number #374

Closed
feonit opened this issue Sep 29, 2016 · 3 comments
Closed

Comments

@feonit
Copy link

feonit commented Sep 29, 2016

I have:

"regions": [
    {
      "id": "177",
      "name": "Moscow"
    }
]

but the request:

GET /regions/177

is empty

If i remove code from test/server/units.js:

    } else if (!isNaN(+value)) {
      return +value
    }

to:

    } else {
      return value
    }

it works fine. What is wrong?

@feonit feonit changed the title can't to use "id" as a string in the case that it looks like a natural number Can't to use "id" as a string in the case that it looks like a natural number Sep 29, 2016
@typicode
Copy link
Owner

typicode commented Oct 5, 2016

Hi @feonit,

You have to use an integer for the id. For example, { "id": 177 } should work fine.
I'm working on improving that on the next branch, so that "177" can be used as well.

But it's not yet ready to be published. I'll update this issue when it'll be available on npm.

@typicode
Copy link
Owner

I've published v0.9.0-beta.2. It should let you use id as string.
It's a beta so there may be some other issues, let me know if you find anything else.

To install it add @next

npm install -g json-server@next

README can be found in next branch.

@typicode
Copy link
Owner

Published v0.9.0 with the fix

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

2 participants