| 40 | // }, [query]); |
| 41 | |
| 42 | const fetchAnimeData = (): void => { |
| 43 | setShowFavorites(false); |
| 44 | |
| 45 | // Define the config we'll need for our Api request |
| 46 | const url = `https://api.jikan.moe/v3/search/anime?q=${query}`; |
| 47 | |
| 48 | // Make the HTTP Api request |
| 49 | fetch(url) |
| 50 | .then((response: Response) => response.json()) |
| 51 | .then((data) => { |
| 52 | setResults([...data.results]); |
| 53 | }) |
| 54 | .catch((error) => { |
| 55 | alert('Error, check console'); |
| 56 | console.error(error); |
| 57 | }); |
| 58 | }; |
| 59 | |
| 60 | const toggleFavoritesSection = () => { |
| 61 | setShowFavorites(!showFavorites); |