I have encountered an issue with retrieving data from my Json Object as I keep getting undefined values,
{
"status": 200,
"message": "Task has been Retrieved",
"employeepanel": {
"taskno": 7,
"taskdate": "2001-06-21",
"createdby": "admin",
"taskdescription": "create the product and deliever it by monday ",
"status": "assigned",
"date": "2001-06-21",
"tenure": 1,
"employee": {
"userId": 30,
"userName": "xyz",
}
}
}
The objective was to find the task by id, with the API responding in this specific format. Now, I am trying to extract the userName from the response.
findbyId(event) {
var selected_id = event.currentTarget.id
const base_URL = 'http://localhost:8091/getbyTaskno/'+selected_id
this.http.get(base_URL, {
}).subscribe(data => {
if (data['status'] == '200' && data['message'] == 'Task has been Retrieved') {
this.userIds=data['employeepanel.employee.userName']
}else{
alert("No task is present for the particular Employee")
} })
}