Skip to content Skip to sidebar Skip to footer

Vanilla Js Dom Manipulation (inconsistent Rendering Of Nodes)

Usually my page looks like this: Take note of the scroll bar on right most part of the image. PROBLEM: sometimes the school logo card would appear at the bottom of the page whenev

Solution 1:

As I mentioned in the comments, you are making two fetch requests that are asynchronous and they are racing to be done first. Whoever wins the race is rendered on top.

So when you fetch the contents, use Promise All

Promise.all([getLogoCard(), getCarouselCard()]).then((values) => {
  values.forEach(card => pageContent.append(card));
});

In your functions, return the fetch call, have the fetch return the element you want to append to the document

functiongetLogoCard() {
  ...
  returnfetch(url)
    .then((response) => response.json())
    .then(function(data){
      ...
      return card; 
    });
}

Post a Comment for "Vanilla Js Dom Manipulation (inconsistent Rendering Of Nodes)"