Skip to content

Commit

Permalink
Insert API request structure
Browse files Browse the repository at this point in the history
  • Loading branch information
w3dd1e committed Nov 19, 2023
1 parent 82bbe30 commit 2894b24
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions front/js/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@ let cartStoredQtys = Object.values(sessionStorage);
let product ={};
let productID = "";

for(let item in cartStoredProduct){
product = JSON.parse(cartStoredProduct[item]);
productID = product.id;}

//API Data Variables
const productAPI = `http://localhost:3000/api/products/${productID}`;

fetch(productAPI)
.then((response) => {
if (!response.ok) {
throw new Error("Failed to retrieve product data.");
}
return response.json();
})
.then((data) => {
window['productData'+`${productID}`] = data;
})
.catch((error) => {
console.error("Error:", error);
});



let newProductCard = `
Expand Down

0 comments on commit 2894b24

Please sign in to comment.