I'm trying to make a get request to json-server to get in a nested object. But it is returning an empty response instead of the object key data.
I have gone through the documentation and there is nothing specific to the db structure that I have.
I want to filter the model array but not getting the model data.
my db.json file is
{
"data": {
"model":
[
{
"name": "BERLINGO",
"manufacturerName": "CITREON",
"id": 1
},
{
"name": "C3",
"manufacturerName": "CITREON",
"id": 2
}
]
}
}
For GET /data , I'm getting the following response.
{
"model": [
{
"name": "BERLINGO",
"manufacturerName": "CITREON",
"id": 1
},
{
"name": "C3",
"manufacturerName": "CITREON",
"id": 2
}
]
}
GET call for /data/model is giving an empty object.
{}
Unfortunately, json-server
does not support such "nested value" syntax. You can GET /data
, but cannot GET /data/model
or GET /data.model
. All you can do is fetching the whole /data
object and access model
field of it.
This is already discussed in json-server
's GitHub Repo, and according to an older discussion, it seems the owner of json-server
(@typicode) does not intend to make this support.