I try to get a JSON file on my local host but on console I receive an array with my all objects from data.json but I receive the following error
Uncaught TypeError: Cannot read property 'forEach' of undefined
This is my code:
$.ajax({
type : 'GET',
dataType : 'json',
url: 'http://localhost:8888/data/folder/data.json',
success : function(data) {
console.log(data);
var data =[];
var covers = document.getElementById("covers");
var blockTemplate = covers.getElementsByTagName("div")[0].cloneNode(true);
covers.getElementsByTagName("div")[0].remove();
data.info.forEach( function(obj) {
block = blockTemplate.cloneNode(true);
block.getElementsByTagName("a")[0].setAttribute('href', obj.link);
block.getElementsByTagName("img")[0].setAttribute('src', obj.cover);
covers.appendChild(block);
});
}
});
Any idea how can I solve this?