Created
June 16, 2020 09:02
-
-
Save chrisjensen/9adf579c066ad1555d97854cc36a7a29 to your computer and use it in GitHub Desktop.
Load Costumes
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
async function loadCostumes(props) { | |
if (get(props, 'global.campaign.mock')) return mockCostumes; | |
try { | |
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(); | |
return body.data.costumeVotes; | |
} catch (error) { | |
console.error(error); | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment