async function insertProducts() {
  let products, prodSection, prodSectionContent, prodNodes;
  prodSectionContent = '';
  prodSection = document.querySelector('#products');
  products = JSON.parse(localStorage.getItem('products'));
  if (!products) {
    products = await fetch('products.json');
    products = await products.json();
    localStorage.setItem('products', JSON.stringify(products));
  }
  products.forEach(prod => { prodSectionContent += createElement(prod) });
  prodSection.innerHTML = prodSectionContent;
}
/**
 * Fetches products from JSON file then creates elements from them and inserts them into page
 */
Fetches products from JSON file then creates elements from them and inserts them into page
Fetches products from JSON file then creates elements from them and inserts them into page
async function insertProducts() {
  let products, prodSection, prodSectionContent, prodNodes;
  prodSectionContent = '';
  prodSection = document.querySelector('#products');
  products = JSON.parse(localStorage.getItem('products'));
  if (!products) {
    products = await fetch('products.json');
    products = await products.json();
    localStorage.setItem('products', JSON.stringify(products));
  }
  products.forEach(prod => { prodSectionContent += createElement(prod) });
  prodSection.innerHTML = prodSectionContent;
}
async function insertProducts ( ) { let products , prodSection , prodSectionContent , prodNodes ; prodSectionContent = '' ; prodSection = document . querySelector ( '#products' ) ; products = JSON . parse ( localStorage . getItem ( 'products' ) ) ; if ( ! products ) { products = await fetch ( 'products.json' ) ; products = await products . json ( ) ; localStorage . setItem ( 'products' , JSON . stringify ( products ) ) ; } products . forEach ( prod => { prodSectionContent += createElement ( prod ) } ) ; prodSection . innerHTML = prodSectionContent ; }
Fetches products from JSON file then creates elements from them and inserts them into page
Fetches products from JSON file then creates elements from them and inserts them into page