typicode / json-server

Get a full fake REST API with zero coding in less than 30 seconds (seriously)
Other
72.59k stars 7k forks source link

Route with ID returns empty object #509

Closed kiemdoder closed 7 years ago

kiemdoder commented 7 years ago

I'm using a JSON file with the following content:

{
  "users": [
    {"id": 1, "name": "Clark Kent", "hero": "Superman"},
    {"id": 2, "name": "Bruce Wayne", "hero": "Batman"},
    {"id": 3, "name": "Peter Parker", "hero": "Spiderman"}
  ]
}

When I use the users route (http://localhost:3000/users) I get back a list of all the user objects:

[
    {
        "id": 1,
        "name": "Clark Kent",
        "hero": "Superman"
    },
    {
        "id": 2,
        "name": "Bruce Wayne",
        "hero": "Batman"
    },
    {
        "id": 3,
        "name": "Peter Parker",
        "hero": "Spiderman"
    }
]

However when I use a route like users/1 I only get back an empty object.

I currently have jsonserver v0.1.6 installed

kiemdoder commented 7 years ago

I see now that the version in this repo is at 0.9.6. I tried this version and it does not have the issue that I raised. I'm new to node, npm etc. so I don't know why I got version 0.1.6 when I installed with npm install -g json-server.