json-server
json-server copied to clipboard
Pushing to a nested array in a resource
Hello!
I have the following resources in my db.json file:
{
"courses": [
{
"id": 1,
"courseName": "Angular",
"courseHours": 120,
"courseStudentList": [
{
"id": 14,
"studentName": "Kennster",
"studentAge": 24
}
],
"courseTeacher": null
},
{
"id": 2,
"courseName": "Vue",
"courseHours": 100,
"courseStudentList": [
{
"id": 3,
"studentName": "Mindy",
"studentAge": 27
},
{
"id": 4,
"studentName": "Ashley",
"studentAge": 22
}
],
"courseTeacher": {
"id": 1,
"teacherName": "Mr. Leon",
"teacherDegree": "PHD"
}
}
]
}
I want to be able to add new objects to the courseStudentList array object property. Can this be done without custom routes?