So currently I am facing a problem where it gives me this error on Google Chrome console…
“dex.js:6 Uncaught (in promise) TypeError: tokens.filter is not a function
at getTop10Tokens (dex.js:6:14)”
async function getTop10Tokens() {
const response = await fetch('https://api.coinpaprika.com/v1/coins');
const tokens = await response.json;
return tokens
.filter(token => token.rank >= 1 && token.rank <= 10)
.map(token => token.symbol);
}
async function getTickerData(tickerList) {
const response = await fetch('https://api.coinpaprika.com/v3.0/56/tokens');
const tokens = await response.json;
const tokenList = Object.values(tokens.tokens);
return tokenList.filter(token => tokenList.includes(token.symbol));
}
getTop10Tokens()
.then(getTickerData)
.then(console.log);
This is my code…