2024-08-04 10:29:43 +02:00
|
|
|
var all_products
|
|
|
|
|
|
2024-08-04 10:19:24 +02:00
|
|
|
async function makeAPIRequest(request) {
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(request);
|
|
|
|
|
const result = await response.json();
|
|
|
|
|
return result
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Error:", error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function loadProducts() {
|
|
|
|
|
const loadProductRequest = new Request("http://127.0.0.1:8000/products")
|
2024-08-04 10:29:43 +02:00
|
|
|
all_products = await makeAPIRequest(loadProductRequest)
|
|
|
|
|
console.log("Loaded products:", all_products)
|
2024-08-04 10:19:24 +02:00
|
|
|
}
|
|
|
|
|
|