1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2025-01-08 20:54:23 +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,26 +10,30 @@ import styles from './404.module.css'
const giphyClient = new GiphyFetch('LfXRwufRyt6PK414G2kKJBv3L8NdnxyR') const giphyClient = new GiphyFetch('LfXRwufRyt6PK414G2kKJBv3L8NdnxyR')
const tag = 'cat' const tag = 'cat'
async function getRandomGif() {
try {
let response = await giphyClient.random({ tag })
const gif = response.data.images.original.mp4
return gif
} catch (error) {
console.error(error.message)
}
}
export default function NotFound() { export default function NotFound() {
const [gif, setGif] = useState('') const [gif, setGif] = useState('')
async function getRandomGif() {
try {
let response = await giphyClient.random({ tag })
const gif = response.data.images.original.mp4
setGif(gif)
} catch (error) {
console.error(error.message)
}
}
async function handleClick(e) { async function handleClick(e) {
e.preventDefault() e.preventDefault()
await getRandomGif() await getRandomGif()
} }
useEffect(() => { useEffect(() => {
getRandomGif() async function init() {
const gif = await getRandomGif()
setGif(gif)
}
init()
}, []) }, [])
return ( return (