1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-23 01:29: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 tag = 'cat'
export default function NotFound() {
const [gif, setGif] = useState('')
async function getRandomGif() {
async function getRandomGif() {
try {
let response = await giphyClient.random({ tag })
const gif = response.data.images.original.mp4
setGif(gif)
return gif
} catch (error) {
console.error(error.message)
}
}
}
export default function NotFound() {
const [gif, setGif] = useState('')
async function handleClick(e) {
e.preventDefault()
@ -29,7 +29,11 @@ export default function NotFound() {
}
useEffect(() => {
getRandomGif()
async function init() {
const gif = await getRandomGif()
setGif(gif)
}
init()
}, [])
return (