Support Forums

My app is not loading correctly on initial load but when I refresh it loads as intended

Good morning, I am getting an Uncaught TypeError: Cannot read property 'forEach' of null error message when I load my app for the first time on a browser. However, if I refresh my page, the error goes away. The app works perfectly on my localhost. So I am having a hard time understanding what is going on. Is it a problem with my code or just a setting that needs to be updated on netlify?

After researching online for a solution, I am still unsure of how to fix this bug so that the page loads correctly when loading on a browser for the very first time.

I am fairly new to developing, so I apologize if this is a very junior question. If anyone could give me some guidance on how to fix this, I would be so grateful. Below is the code snippet the error is referencing and the link to the app I’m referencing. Cheers!


const drawCharTiles = (coll = "char-collection_0", searchResult = "") => {
  const charContainer = document.querySelector(".sw-main .sw-main__characters");
  charContainer.innerHTML = ``;
  let data = [];
  if (searchResult.length > 0) {
    data = searchResult;
    data.forEach((item) => {
      charContainer.innerHTML += drawCharacterBase(item, item["coll"]);
  } else {
    data = getData(coll);
    data.forEach((item) => {
      charContainer.innerHTML += drawCharacterBase(item, coll);


Welcome to the forum @mdelcore

I did not see this error on initial page load, the character tiles displayed. Have you fixed it?

I did see

Error in pageFetch: ReferenceError: swLoader is not defined

And the search function is not returning any results.