Skip to content

Instantly share code, notes, and snippets.

@ElpixZero
Created July 3, 2021 16:24
Show Gist options
  • Save ElpixZero/33b719e1ecd212b77f5b556959306471 to your computer and use it in GitHub Desktop.
Save ElpixZero/33b719e1ecd212b77f5b556959306471 to your computer and use it in GitHub Desktop.
const API_KEY =
"ce3fd966e7a1d10d65f907b20bf000552158fd3ed1bd614110baa0ac6cb57a7e";
//TODO: refactor to use URLSearchParams
fetch(
`https://min-api.cryptocompare.com/data/pricemulti?fsyms=${[
...tickersHandlers.keys()
].join(",")}&tsyms=USD&api_key=${API_KEY}`
)
//AFTER REFACTORING
const LOAD_TICKERS_API_ENDPOINT = new URL('https://min-api.cryptocompare.com/data/pricemulti');
LOAD_TICKERS_API_ENDPOINT.searchParams.set('fsyms', [
...tickersHandlers.keys()
].join(","));
LOAD_TICKERS_API_ENDPOINT.searchParams.set('tsyms', 'USD');
LOAD_TICKERS_API_ENDPOINT.searchParams.set('api_key', API_KEY);
fetch(LOAD_TICKERS_API_ENDPOINT.href)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment