Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
JSON Server routing/filtering

I'm making my first React app, and I'm using json-server as a fake backend. It's a workout planner app, and I'm trying to figure out how to add exercises to each day. What I have is the feature to add new exercises, and now I'm trying to add these exercises to each date.

 "dates": [
{
  "id": 22102021,
  "exercises": [
    {
      "id": 0,
      "name": "Squats",
      "amount": "3x10"
    }
  ]
},
{
  "id": 23102021,
  "exercises": [
    {
      "id": 0,
      "name": "Bicep curls",
      "amount": "3x8"
    }
  ]
}]

This is the dates array that I have in my db.json, the date is the id, and I'm trying to access the exercises array to add more exercises.

 await fetch(`http://localhost:8000/dates?id=${ID}`, {
  method: "POST",
  headers: {
    "Content-type": "application/json",
  },
  body: JSON.stringify(exercise),
});

This is a part of the function that adds the exercises, the fetch function is where I'm confused. How do I access the exercises array inside the object? I suppose I have to write the id of the date, but if I add an exercise now, it looks like this.

  "dates": [
{
  "id": 22102021,
  "exercises": [
    {
      "id": 0,
      "name": "Squats",
      "amount": "3x10"
    }
  ]
},
{
  "id": 23102021,
  "exercises": [
    {
      "id": 0,
      "name": "Bicep curls",
      "amount": "3x8"
    }
  ]
},
{
  "name": "deadlifts",
  "amount": "3x12",
  "id": 23102022
}]

EDIT: found an almost exact unanswered problem here.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!