I invoked a callback onload
and it worked but left a TypeError: Failed to execute 'addEventListener' on 'EventTarget': parameter 2 is not of type 'Object'
in the console
document.addEventListener('load', setTimeout(callBack, 2000));
function callBack(){
const data = JSON.parse(localStorage.data);
const tbody = document.getElementById("info");
for (let obj in data){
let td = document.createElement('td');
let text = document.createTextNode(`${data[obj]}`);
td.appendChild(text);
tbody.appendChild(td);
}
};
There's a similar question here that prompted these changes:
document.addEventListener('load', function(){setTimeout(callBack, 2000)});
document.addEventListener('load', function(){setTimeout(callBack(), 2000)});
It doesn't display and I get no exceptions with the changes.
EDIT:
On changing the event listener line, I get no data in my HTML- so callBack
is not being handled or called.