iamshaunjp / Complete-React-Tutorial

All course files for the Complete React Tutorial on the Net Ninja YouTube channel.
1.81k stars 1.72k forks source link

Lesson 16 - JSON Server - id field must be String in db.json #36

Open stav19 opened 8 months ago

stav19 commented 8 months ago

I have encountered a syntax change related to the id field in the json-server package when upgrading to version 1.0.0-alpha.20. The id field of an data object was previously an integer, and in the updated version, it is expected to be a string.

Consider this example form "https://www.npmjs.com/package/json-server":

              {
                "posts": [
                  { "id": "1", "title": "a title" },
                  { "id": "2", "title": "another title" }
                ],
                "comments": [
                  { "id": "1", "text": "a comment about post 1", "postId": "1" },
                  { "id": "2", "text": "another comment about post 1", "postId": "1" }
                ],
                "profile": {
                  "name": "typicode"
                }
              }