Skip to content

Instantly share code, notes, and snippets.

@chrisjensen
Last active June 16, 2020 08:51
Show Gist options
  • Save chrisjensen/d77c82f752b5cc01d0b00c6ddeb4028c to your computer and use it in GitHub Desktop.
Save chrisjensen/d77c82f752b5cc01d0b00c6ddeb4028c to your computer and use it in GitHub Desktop.
Load Highest Donor
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