Get Quote Form Troubleshooting

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…



Follow Up

1 Like

Hey @f41z37, hope you are well.

You forgot to add () at the end of json (which is a method that returns a JSON object)
https://developer.mozilla.org/en-US/docs/Web/API/Response/json

const tokens = await response.json();

Let me know the result :slight_smile:

Carlos Z

1 Like

To be fair, It was 3am … xD

This worked
Thank you!

1 Like