From 26fb8073ed3504cec3d659874f807b04eb802815 Mon Sep 17 00:00:00 2001 From: Yarne Coppens Date: Sun, 4 Aug 2024 10:29:43 +0200 Subject: [PATCH] Load products on page load --- index.html | 19 ++++++++++++++----- scripts/main.js | 6 ++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index b534314..9948837 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,14 @@ - - - - -

\ No newline at end of file + + + + + + Toddler Shop + + + + + + + + diff --git a/scripts/main.js b/scripts/main.js index dcf0000..11bf7d8 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -1,3 +1,5 @@ +var all_products + async function makeAPIRequest(request) { try { const response = await fetch(request); @@ -10,7 +12,7 @@ async function makeAPIRequest(request) { async function loadProducts() { const loadProductRequest = new Request("http://127.0.0.1:8000/products") - const result = await makeAPIRequest(loadProductRequest) - console.log(result) + all_products = await makeAPIRequest(loadProductRequest) + console.log("Loaded products:", all_products) } \ No newline at end of file