MCPcopy Create free account
hub / github.com/SuboptimalEng/coding-tutorials / fetchAnimeData

Function fetchAnimeData

react-anime/src/App.tsx:42–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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);

Callers 1

AppFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected