Skip to content

Instantly share code, notes, and snippets.

@karanjamutahi
Last active June 30, 2022 08:41
Show Gist options
  • Save karanjamutahi/eb5d5a1d10c76d29b6c0bd32729fc146 to your computer and use it in GitHub Desktop.
Save karanjamutahi/eb5d5a1d10c76d29b6c0bd32729fc146 to your computer and use it in GitHub Desktop.
const cartBtn=document.querySelector(".cart-btn");
const CloseCartBtn=document.querySelector(".close-cart");
const clearCartBtn=document.querySelector(".clear-cart");
const cartDOM=document.querySelector(".clear");
const cartOverlay=document.querySelector(".cart-overlay");
const cartItmes=document.querySelector(".cart-items");
const cartTotal=document.querySelector(".cart-total");
const cartContent=document.querySelector(".cart-content");
const productsDOM=document.querySelector(".products-center");
//cart items variable let cart =[];
//getting the products in form of variable
class Products{
async getProducts(){
try{
let result =await fetch("products.json");
let data=await result.json();
let products=data.items;
products=products.map(item=>{
const {title,price}=item.fields;
const {id} = item.sys const image=item.fields.image.fields.file.url;
return {title,price,id,image};
});
return products;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment