0

I'm using json-server to host a json file, I can fetch the whole file using GET but I don't know how to get access to just a specific nested part of the json. I thought doing http://localhost:3004/data?program=Day%201 would return only the "Day 1" but instead, I got the whole file.What can I do?

{
  "data": {
  "user": {"username": "Pedro", "id":1 },
  "program":{
     "Day 1" :[
        {
          "muscleGroup": "Chest",
          "warmUp": ["parallel bar dips"],
          "main": ["Bench Press", "Inclined Bench press", "Decline Bench press"],
          "secondary": ["Dumbbell Flys", "Cable Crossover Flys", "Pec-deck Fly"]
        },
        {
          "muscleGroup": "Biceps",
          "main": ["Barbell Curl", "Preacher Curl"],
          "secondary": ["Hammer Curls", "Cable Curl", "Dumbbell Curl"]
        }
      ],
      "Day 2" : [
        {
          "muscleGroup": "Shoulders",
          "warmUp": ["parallel bar dips"],
          "main": ["Bench Press", "Inclined Bench press", "Decline Bench press"],
          "secondary": ["Dumbbell Flys", "Cable Crossover Flys", "Pec-deck Fly"]
        },
        {
          "muscleGroup": "Abs",
          "main": ["Crunch", "Leg raises"]
         }
      ],
        }
}
}

1 Answer 1

2

You cant do that, it is impossible. You need to fetch your json, then get your data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.