1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2025-02-14 21:10:41 +01:00
This commit is contained in:
Matthias Kretschmann 2021-02-06 14:44:24 +01:00
parent 2569fc6218
commit 820baca23f
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -10,18 +10,18 @@ import styles from './404.module.css'
const giphyClient = new GiphyFetch('LfXRwufRyt6PK414G2kKJBv3L8NdnxyR') const giphyClient = new GiphyFetch('LfXRwufRyt6PK414G2kKJBv3L8NdnxyR')
const tag = 'cat' const tag = 'cat'
export default function NotFound() { async function getRandomGif() {
const [gif, setGif] = useState('')
async function getRandomGif() {
try { try {
let response = await giphyClient.random({ tag }) let response = await giphyClient.random({ tag })
const gif = response.data.images.original.mp4 const gif = response.data.images.original.mp4
setGif(gif) return gif
} catch (error) { } catch (error) {
console.error(error.message) console.error(error.message)
} }
} }
export default function NotFound() {
const [gif, setGif] = useState('')
async function handleClick(e) { async function handleClick(e) {
e.preventDefault() e.preventDefault()
@ -29,7 +29,11 @@ export default function NotFound() {
} }
useEffect(() => { useEffect(() => {
getRandomGif() async function init() {
const gif = await getRandomGif()
setGif(gif)
}
init()
}, []) }, [])
return ( return (