// Meals
export async function searchIngredient(ingrediente: string) {
console.log('meu location', window.location.pathname);
try {
const response = await fetch(`https://www.themealdb.com/api/json/v1/1/filter.php?i=${ingrediente}`);
const data = await response.json();
return data.meals;
} catch (err) {
console.error(err);
}
}
export async function searchFirstLetter(primeiraletra: string) {
try {
const response = await fetch(`https://www.themealdb.com/api/json/v1/1/search.php?f=${primeiraletra}`);
const data = await response.json();
return data.meals;
} catch (err) {
console.error(err);
}
}
export async function searchName(nome: string) {
try {
const response = await fetch(`https://www.themealdb.com/api/json/v1/1/search.php?s=${nome}`);
const data = await response.json();
return data.meals;
} catch (err) {
console.error(err);
}
}
// Drinks
export async function searchDrinkIngredient(ingrediente: string) {
try {
const response = await
fetch(`www.thecocktaildb.com/api/json/v1/1/filter.php?i=${ingrediente}`);
const data = await response.json();
return data.cocktails;
} catch (err) {
console.error(err);
}
}
export async function searchDrinkFirstLetter(primeiraletra: string) {
try {
const response = await
fetch(`www.thecocktaildb.com/api/json/v1/1/filter.php?f=${primeiraletra}`);
const data = await response.json();
return data.cocktails;
} catch (err) {
console.error(err);
}
}
export async function searchDrinkName(nome: string) {
try {
const response = await
fetch(`www.thecocktaildb.com/api/json/v1/1/filter.php?s=${nome}`);
const data = await response.json();
return data.cocktails;
} catch (err) {
console.error(err);
}
}
function mealsOrDrinks() {
const end_POINTS_MEALS =
const END_POINT_DRINKS =
const [searchType, setSearchType] = useState('ingredient');
const [searchText, setSearchText] = useState('');
const [resultsMealSearch, setResultsMealSearch] = useState([]);
const [resultsDrinkSearch, setResultsDrinkSearch] = useState([]);
switch (window.location.pathname) {
case '/meals':
return(
);
case '/drinks':
return(
);
default:
}
return(
);
}