Вы должны присваивать объект переменной, как здесь, я назначаю переменную val
. Вы можете получить доступ к свойствам, как показано ниже. Вы можете запустить фрагмент здесь и посмотреть вывод
let val = {
"data": [
{
"id": 2,
"addEmployee": {
"firstName": "Devansh"
},
"attendances": [
{
"id": 3,
"checkIn": "2020-02-18T04:36:45.000Z",
"checkOut": "2020-02-18T11:46:16.000Z",
"totalHours": "7:9",
"date": "2020-02-18",
"status": "present",
"createdAt": "2020-02-18T04:36:45.000Z",
"updatedAt": "2020-02-18T11:46:16.000Z",
"userId": 2
}
]
}
]
}
val.data.forEach(eachData => {
console.log('Employee Name ---> ',eachData.addEmployee.firstName);
eachData.attendances.forEach(atten => {
console.log('attendance Object -->',atten);
})
});