I'm trying to return results to frontend from backend but would like to remove some of the data taken from the query.
I'm currently able to remove it for the first object in the array but would like to do it for every object.
const { url, booking_created, booking_date, student_id, student_name, ...sendEvent} = bookedSlots[0]
sending sendEvent
returns
{
"id": 1,
"start": "2022-09-28T19:00:00.000Z",
"end": "2022-09-28T20:00:00.000Z",
"duration": "60MIN",
"title": "1 hour lao lessons",
"tutor_id": "901"
}
I'm not sure how to loop through the object and apply this to everything.
{
"0": {
"id": 1,
"booking_created": "2022-09-24T19:49:00.000Z",
"booking_date": "2022-09-24T00:00:00.000Z",
"start": "2022-09-28T19:00:00.000Z",
"end": "2022-09-28T20:00:00.000Z",
"duration": "60MIN",
"student_id": 1,
"student_name": "Bob the builder",
"title": "1 hour lessons",
"url": "nan",
"tutor_id": "901"
},
"1": {
"id": 2,
"booking_created": "2022-09-24T20:25:15.000Z",
"booking_date": "2022-09-24T00:00:00.000Z",
"start": "2022-09-28T21:00:00.000Z",
"end": "2022-09-28T22:00:00.000Z",
"duration": "60MIN",
"student_id": 1,
"student_name": "Big boss 1",
"title": "1 hour lessons",
"url": "nan",
"tutor_id": "901"
},
"2": {
"id": 3,
"booking_created": "2022-09-28T12:00:13.000Z",
"booking_date": "2022-09-08T00:00:00.000Z",
"start": "2022-09-28T18:00:00.000Z",
"end": "2022-09-28T19:00:00.000Z",
"duration": "60MIN",
"student_id": 1,
"student_name": "bobo",
"title": "bob lesson",
"url": "123",
"tutor_id": "901"
}
}