I'm trying to filter out data from fetch of an external API (CoinMarketCap) in React.
I only want the data for a specific set of tickers, but after numerous attempts I can't seem to get it to work correctly. I feel like this should be an easy fix, but can't seem to figure it out.
getData = () => {
const tickers = ["btc", "xrp", "eth", "ltc", "bch", "etc", "str", "xmr", "nxt", "zec", "rep", "dash"];
fetch(`https://api.coinmarketcap.com/v1/ticker`)
.then(res => res.json())
.then(data => data.filter(d => tickers.includes(d.symbol)))
.then(results => console.log(results)
)
But it's logging out an empty array. Any ideas?
array#filtercallback should befilter(d => tickers.includes(d.symbol.toLowerCase()))