Untitled
unknown
plain_text
2 years ago
631 B
9
Indexable
export function mealsOrDrinks() { let END_POINT = ''; const END_POINT_MEALS = 'https://www.themealdb.com/api/json/v1/1/filter.php?'; const END_POINT_DRINKS = 'https://www.thecocktaildb.com/api/json/v1/1/filter.php?'; switch (window.location.pathname) { case '/meals': END_POINT = END_POINT_MEALS; break; case '/drinks': END_POINT = END_POINT_DRINKS; break; default: return false; } async function api(ingrediente: string, tipo: string) { const response = await fetch(`${END_POINT}${tipo}=${ingrediente}`); const data = await response.json(); return data.meals; }
Editor is loading...