json-server icon indicating copy to clipboard operation
json-server copied to clipboard

Getting nested resources doesn't work

Open pchabros opened this issue 1 year ago • 1 comments

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

pchabros avatar Jun 04 '24 11:06 pchabros