I get undefined when i try to console.log it
var farr = [];
$.ajax({
url: "https://whispering-cliffs-33347.herokuapp.com/employees",
type: "GET",
contentType: "application/jsonp"
}).done(function(employees) {
for(let i in employees){
farr.push(employees[i]);
}
})
console.log(farr[8]);
Any ideas?
employees. Know whether it is array or object. If it is array, you may need to parse the JSON. And use console in.donefunction.console.logcall into your.done()callback. Remember that$.ajaxis asynchronous and any return values or variables you're setting in the callback will be undefined outside of the callback.async:false. It's deprecated, it's lazy and it's poor programming practice.