19 lines
529 B
JavaScript
19 lines
529 B
JavaScript
|
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);
|
||
|
}
|
||
|
}
|