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)