17 lines
430 B
JavaScript
17 lines
430 B
JavaScript
|
import { fetchAllProducts } from "./api/fetchAllProducts.js";
|
||
|
import { getMenuItemHTML } from "./helpers/getMenuItemHTML.js";
|
||
|
import { menuList } from "./variables.js";
|
||
|
|
||
|
if (menuList) drawAllProducts();
|
||
|
|
||
|
async function drawAllProducts() {
|
||
|
try {
|
||
|
const data = await fetchAllProducts();
|
||
|
|
||
|
for (const product of data) {
|
||
|
menuList.innerHTML += getMenuItemHTML(product);
|
||
|
}
|
||
|
} catch (err) {
|
||
|
console.log(err);
|
||
|
}
|
||
|
}
|