-
-
Save cupofcodeblog/75ef94f078c4437bff0adb3cb7f1ebad to your computer and use it in GitHub Desktop.
Wordle part 3 - pre-external json
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
function App() { | |
... | |
useEffect(() => { | |
fetch('http://localhost:3001/solutions') | |
.then(res => res.json()) | |
.then(json => { | |
// random int between 0 & 14 | |
const randomSolution = json[Math.floor(Math.random()*json.length)] | |
setSolution(randomSolution.word) | |
setSplit(JSON.parse(randomSolution.split)); | |
}) | |
}, []) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment