Reputation: 1
This is my code:
var images = new Parse.Query("Images");
var bunny_data = [];
images.equalTo("indexImg","T");
images.find({
success: function(objects) {
for(var i = 0;i<=objects.length;i++){
var object = objects[i];
object.get('imgUrl');
};
},
error: function(error) {
console.log("An error occured :(");
}
});
console.log(bunny_data);
The console is:
[]
myjs.js:65 Uncaught TypeError: Cannot read property 'get' of undefined
Upvotes: 0
Views: 915
Reputation: 224983
for(var i = 0;i<=objects.length;i++){
The <=
means this loops from 0
to objects.length
inclusive, but length is an exclusive upper bound on an array’s indices. Use <
instead.
Upvotes: 1