Last active
June 16, 2020 08:51
-
-
Save chrisjensen/d77c82f752b5cc01d0b00c6ddeb4028c to your computer and use it in GitHub Desktop.
Load Highest Donor
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
useEffect(() => { | |
async function fetchData() { | |
const response = await fetch(url); | |
if (!response.ok) { | |
console.error(await response.text()); | |
throw new Error('Could not load. Try refreshing the page'); | |
} | |
const body = await response.json(); | |
const [topDonor, secondDonor] = body.data.donors; | |
if (topDonor) { | |
setLeadDonor(topDonor.preferredName); | |
setHighestGift(topDonor.total); | |
} | |
} | |
fetchData() | |
.catch(e => console.error(e)); | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment