Getting addresses from 1inch API

I can’t get addresses from top 10 coins from 1Inch API?
I can’t recognize what is wrong?

API_URL = 'https://api.coinpaprika.com/v1/coins'
API_URL1 = 'https://api.1inch.exchange/v3.0/1/tokens'
    let response = await fetch(API_URL);
    let data = await response.json();
    let listItems = data.filter(token => token.rank <= 10 && token.rank >= 1).map(token => token.symbol);
    //console.log(data.name)

    console.log(listItems);
}
async function getAddresses(tickerList){
    let response1 = await fetch(API_URL1)
    let tokens = await response1.json()
    let addrs = Object.values(tokens.tokens)
    //let top10 = tokens.filter(token => token.address  ).map(token => token.symbol);
    //console.log("addrs", addrs)
    return addrs.filter(token => tickerList.includes(token.symbol))
}

getTop10()
    .then(getAddresses)
    .then(console.log)

Got this error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'includes')
    at Coinpaprika.js:34:45
    at Array.filter (<anonymous>)
    at getAddresses (Coinpaprika.js:34:18)

It would be easier if you can create a github repo for your project, that way i can replicate your issue easily :nerd_face:

Carlos Z

Here is my github repo:
https://github.com/Lane689/JS-course---DEX.git

1 Like

Your code works perfectly from my side.

You can also check it here, i just copy/paste your code.
https://codepen.io/thecil/pen/zYapxjv?editors=0011

Carlos Z