Int_Prog/лаб3/lab3/public/scripts/item.js

19 lines
529 B
JavaScript
Raw Normal View History

2024-01-18 23:29:33 +04:00
import { getParamId } from "./helpers/getParamId.js";
import { fetchProductById } from "./api/fetchProductById.js";
import { getItemHTML } from "./helpers/getItemHTML.js";
import { itemContainer } from "./variables.js";
if (itemContainer) drawProduct();
async function drawProduct() {
const productId = getParamId();
if (!productId) return alert("Ошибка!");
try {
const data = await fetchProductById(productId);
itemContainer.innerHTML = getItemHTML(data[0]);
} catch (err) {
console.log(err);
}
}