forked from Technigo/js-project-recipe-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathj-checkpoints.s
194 lines (189 loc) · 4.06 KB
/
j-checkpoints.s
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
const BASE_URL = "https://api.spoonacular.com/recipes/random";
const API_KEY = "e6dc8a39f6e14b3cac66bfcca7d84130";
const API_URL = `${BASE_URL}/?apiKey=${API_KEY}&number=150`;
const fetchRecipes = async () => {
try {
const response = await fetch(API_URL);
if (!response.ok) {
throw new Error(`Error! status: ${response.status}`);
}
const data = await response.json();
console.log(data);
const validRecipes = data.recipes.filter(recipe => {
return recipe.cuisines.length > 0 && recipe.image && recipe.title;
});
console.log(validRecipes);
return validRecipes;
} catch (error) {
console.error(error.message);
}
};
fetchRecipes();
//render valid recipes in the DOM
// renderRipes(validRecipes)
// return validRecipes
// render valid recipes in the DOM
// renderRecipes(validRecipes)
// return validRecipes
fetchRecipes();
const recipes = [
{
id: 1,
title: "Vegan Lentil Soup",
image: "./chicken.webp",
readyInMinutes: 30,
servings: 4,
sourceUrl: "https://example.com/vegan-lentil-soup",
diets: ["vegan"],
cuisine: "Mediterranean",
ingredients: [
"red lentils",
"carrots",
"onion",
"garlic",
"tomato paste",
"cumin",
"paprika",
"vegetable broth",
"olive oil",
"salt"
],
pricePerServing: 2.5,
popularity: 85
},
{
id: 2,
title: "Vegetarian Pesto Pasta",
image: "./chicken.webp",
readyInMinutes: 25,
servings: 2,
sourceUrl: "https://example.com/vegetarian-pesto-pasta",
diets: ["vegetarian"],
cuisine: "Italian",
ingredients: [
"pasta",
"basil",
"parmesan cheese",
"garlic",
"pine nuts",
"olive oil",
"salt",
"black pepper"
],
pricePerServing: 3.0,
popularity: 92
},
{
id: 3,
title: "Gluten-Free Chicken Stir-Fry",
image: "./chicken.webp",
readyInMinutes: 20,
servings: 3,
sourceUrl: "https://example.com/gluten-free-chicken-stir-fry",
diets: ["gluten-free"],
cuisine: "Asian",
ingredients: [
"chicken breast",
"broccoli",
"bell pepper",
"carrot",
"soy sauce (gluten-free)",
"ginger",
"garlic",
"sesame oil",
"cornstarch",
"green onion",
"sesame seeds",
"rice"
],
pricePerServing: 4.0,
popularity: 78
},
{
id: 4,
title: "Dairy-Free Tacos",
image: "./chicken.webp",
readyInMinutes: 15,
servings: 2,
sourceUrl: "https://example.com/dairy-free-tacos",
diets: ["dairy-free"],
cuisine: "Mexican",
ingredients: [
"corn tortillas",
"ground beef",
"taco seasoning",
"lettuce",
"tomato",
"avocado"
],
pricePerServing: 2.8,
popularity: 88
},
{
id: 5,
title: "Middle Eastern Hummus",
image: "./chicken.webp",
readyInMinutes: 10,
servings: 4,
sourceUrl: "https://example.com/middle-eastern-hummus",
diets: ["vegan", "gluten-free"],
cuisine: "Middle Eastern",
ingredients: [
"chickpeas",
"tahini",
"garlic",
"lemon juice",
"olive oil"
],
pricePerServing: 1.5,
popularity: 95
},
{
id: 6,
title: "Quick Avocado Toast",
image: "./chicken.webp",
readyInMinutes: 5,
servings: 1,
sourceUrl: "https://example.com/quick-avocado-toast",
diets: ["vegan"],
cuisine: "Mediterranean",
ingredients: [
"bread",
"avocado",
"lemon juice",
"salt"
],
pricePerServing: 2.0,
popularity: 90
},
{
id: 7,
title: "Beef Stew",
image: "./chicken.webp",
readyInMinutes: 90,
servings: 5,
sourceUrl: "https://example.com/beef-stew",
diets: [],
cuisine: "European",
ingredients: [
"beef chunks",
"potatoes",
"carrots",
"onion",
"garlic",
"tomato paste",
"beef broth",
"red wine",
"bay leaves",
"thyme",
"salt",
"black pepper",
"butter",
"flour",
"celery",
"mushrooms"
],
pricePerServing: 5.5,
popularity: 80
}
]