Search code examples
json-server

Problems with Get request from browser in json-server


I am trying to access through my browser to see what I get from my json database.

Here's an example:

     {
          "records": [
            {
              "data": {
                "Identification number": "34",
                "Name": "Joqmo",
                "Gender": "female",
                "Risk": "BITES",
                "Hair length": "6.2000000000",
                "IQ": "98",
                "Admission date": "Mon Dec 13 00:00:00 CET 1993",
                "Last breakdown": "Wed Dec 24 07:14:50 CET 2014",
                "Yearly fee": "67035",
                "Knows the Joker?": "true"
              },
              "kids": {
                "has_relatives": {
                  "records": [
                    {
                      "data": {
                        "Relative ID": "1007",
                        "Patient ID": "34",
                        "Is alive?": "true",
                        "Frequency of visits": "29"
                      },
                      "kids": {
                        "has_phone": {
                          "records": [
                            {
                              "data": {
                                "Phone ID": "2008",
                                "ID of the relative": "1007",
                                "Phone": "+(179)-982-0570"
                              },
                              "kids": {}
                            }
                          ]
                        }
                      }
                    }
                  ]
                }
              }
            }
    }
]
}

Then I can access to localhost:5000/records and all the info shows perfectly. But when trying to access a level deeper, to localhost:5000/records/0 which is the first element in the array and I should be able to see "data" and "kids" in the first level, but it sends a 404.

Any idea???


Solution

  • I read that json-library has limitations on this and You cannot access data this way unless the data is structure with ids in the same way explained in the docs data Examples.