You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found this front-end tools from https://rtool.cn/jsonserver/docs/relationships, and I download the db.json to localhost, and command the stings "json-server --watch db.json"
Then I use http://localhost:3000/posts/1?_embed=comments, json resualt return like this
{
"userId": 1,
"id": "1",
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto",
"comments": []
}
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto",
"comments": [
{
"postId": 1,
"id": 1,
"name": "id labore ex et quam laborum",
"email": "[email protected]",
"body": "laudantium enim quasi est quidem magnam voluptate ipsam eos\ntempora quo necessitatibus\ndolor quam autem quasi\nreiciendis et nam sapiente accusantium"
},……
]
}
so I find the diffence:
the website json return "id": 1 , id value is 1,but the local json return "id": "1", id value is "1".so why could this happen?
The text was updated successfully, but these errors were encountered:
Yes, this is my problem too.
And When the id property is a number, when we request the following endpoint, the value Not Found
But when the id property is a string, when we request the same endpoint, it will return the desired data.
This problem did not exist in the early versions
I found this front-end tools from https://rtool.cn/jsonserver/docs/relationships, and I download the db.json to localhost, and command the stings "json-server --watch db.json"
Then I use http://localhost:3000/posts/1?_embed=comments, json resualt return like this
{
"userId": 1,
"id": "1",
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto",
"comments": []
}
but when I use the url https://jsonplaceholder.typicode.com/posts/1?_embed=comments, json resualt return like this
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto",
"comments": [
{
"postId": 1,
"id": 1,
"name": "id labore ex et quam laborum",
"email": "[email protected]",
"body": "laudantium enim quasi est quidem magnam voluptate ipsam eos\ntempora quo necessitatibus\ndolor quam autem quasi\nreiciendis et nam sapiente accusantium"
},……
]
}
so I find the diffence:
the website json return "id": 1 , id value is 1,but the local json return "id": "1", id value is "1".so why could this happen?
The text was updated successfully, but these errors were encountered: