Created
August 13, 2021 15:15
-
-
Save codemile/77361fa9fc051f0b3817edb2929488c8 to your computer and use it in GitHub Desktop.
Hook that fetches a random Games Of Thrones quote.
This file contains 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
import {useEffect, useState} from 'react'; | |
const useGotQuote = () => { | |
const [quote, setQuote] = useState(''); | |
useEffect(() => { | |
fetch('https://game-of-thrones-quotes.herokuapp.com/v1/random') | |
.then((response) => response.json()) | |
.then((data) => setQuote(data?.sentence)); | |
}, []); | |
return quote; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment