Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created January 6, 2020 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/4b1c04fd4a09726a9849eb15a938f3f0 to your computer and use it in GitHub Desktop.
Save BetterProgramming/4b1c04fd4a09726a9849eb15a938f3f0 to your computer and use it in GitHub Desktop.
...
const getCoinData = async (startDate, endDate) => {
...
const startDateUnix = dayjs(startDate).format("X");
const endDateUnix = dayjs(endDate).format("X");
const range = `range?vs_currency=usd&from=${startDateUnix}&to=${endDateUnix}`;
const url = `${APIURL}/coins/bitcoin/market_chart/${range}`;
try {
const coinResponse = await fetch(url);
const data = await coinResponse.json();
setCoinData(data);
setError(false);
setIsLoading(false);
} catch (e) {
setIsLoading(false);
setError(e);
}
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment