typicode / json-server

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

Getting nested resources doesn't work #1556

Open pchabros opened 4 months ago

pchabros commented 4 months ago

This does not work for me. Returns Not found. I use version ^1.0.0-beta.0.


For nested resources to work, you need to structure your db.json this way:

{
  "environments": [
    { "id": 12 },
    { "id": 19 }
  ],
  "reports": [
    { "id": 17, "environmentId": 12 },
    { "id": 25, "environmentId": 12 }
  ]
}

Then /environments/12/reports should return reports that have environmentId === 12

Originally posted by @typicode in https://github.com/typicode/json-server/issues/72#issuecomment-99162206

Tzal3x commented 3 months ago

Same issue for me: https://github.com/typicode/json-server/issues/1567

Did you get over this somehow? What runtime are you using? npm/bun/deno?