I have an ajax function that returns data and I want to push the objects
name into an array but when I check the console, it keeps saying undefined. How can I print the certain attribute only?
$.ajax({
url: 'http://localhost:3000/list',
type: 'get',
success: function(response){
console.log(response);
console.log(response.name);
},
error: function(){
console.log('err');
}
});
When I check the results on console
//console.log(response);
(3) [{...}, {...}, {...}]
1: {_id: "1", name: "a"}
2: {_id: "2", name: "b"}
3: {_id: "3", name: "c"}
//console.log(response.name);
(3)undefined