DEV Community

Discussion on: A PWA to fetch news headlines from news APIs.

Collapse
 
aravindballa profile image
Aravind Balla

Hi Sambit, nice post!

I had a look at the code and here are few thoughts.

  • Do you really need createNode function? It is like renaming document.createElement() method. (same with append)
  • You can use template literals to create all the inner elements and use innerHTML once to put that in the node

    const node = document.createElement('div');
    node.innerHTML = `<li><span>${title}</span><p>${abstract}</p></li>`
    

Hope it helps.

Collapse
 
sambitsahoojs profile image
sambit sahoo

Thank you for the insight.
It's amazing to see a more efficient way to achieve same result.