I'm currently working on a project, in which I have to load an array from localStorage and from this loop through it to generate elements.
I have the saving process working as expected, however when it comes down to loading it - I recieve the following error.
TypeError: undefined is not a function (evaluating 'mainInfo.forEach')
Below you are able to see the code which is throwing this error.
var mainInfo = [];
var subInfo = [];
mainInfo = localStorage.StaffAppMainList;
subInfo = localStorage.StaffAppSubList;
finalOutput = "";
console.log(mainInfo.length);
mainInfo.forEach(function(item) {
var theTitle = item.title;
var url = "Pages/SubInfo.html?info=" + theTitle;
finalOutput = finalOutput + "<li><a href='" + url + "'>" + item.title + "</a></li>";
$("#homeList").html(finalOutput).listview().listview("refresh");
});
The line the error is thrown on is -
mainInfo.forEach(function(item) {
Currently I'm unsure of what is causing this error, and so any advice will be greatly appreciated.