Last active
April 18, 2025 16:17
-
-
Save SafaElmali/99c646418ce6cc2493a3f4ebe4c46510 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
const fetchTrendingGifs = async () => { | |
try { | |
const response = await fetch( | |
`https://api.giphy.com/v1/gifs/trending?api_key=${import.meta.env.VITE_GIPHY_API_KEY}&limit=25` | |
); | |
if (!response.ok) { | |
throw new Error(`HTTP error! status: ${response.status}`); | |
} | |
const data = await response.json(); | |
setGifs(data.data); | |
setLoading(false); | |
} catch (error) { | |
handleError(error as Error); | |
} | |
}; | |
fetchTrendingGifs(); | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment