-
Notifications
You must be signed in to change notification settings - Fork 1
/
category.js
36 lines (21 loc) · 892 Bytes
/
category.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const catcontainer = document.querySelector(" .card-container");
const headingCat = document.querySelector(".heading");
let Mealname = window.location.search.slice(1).split("&")[0].split("=")[1];
let Mealharf = window.location.search.slice(1).split("&")[1].split("=")[1];
console.log(Mealname);
console.log(Mealharf);
const url = `https://www.themealdb.com/api/json/v1/1/filter.php?${Mealharf}=${Mealname}`;
async function getCatApi(url) {
const response = await fetch(url);
const data = await response.json();
return data;
}
function showCategory() {
catcontainer.innerHTML = "";
getCatApi(url).then(res => {
headingCat.innerHTML = `${Mealname} category meals`;
const catmeal = res.meals;
Meals.showReasult(catmeal, catcontainer);
}).catch(err => console.log(err));
}
document.addEventListener("DOMContentLoaded", showCategory);