Skip to content

Instantly share code, notes, and snippets.

@cupofcodeblog
Created February 23, 2024 08:00
Show Gist options
  • Save cupofcodeblog/75ef94f078c4437bff0adb3cb7f1ebad to your computer and use it in GitHub Desktop.
Save cupofcodeblog/75ef94f078c4437bff0adb3cb7f1ebad to your computer and use it in GitHub Desktop.
Wordle part 3 - pre-external json
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