HI everyone
im at the moralis section and I keep getting this error code and for the life of me can not see where the problem is
any help would be greatly appreciated
dex.js:21 Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
at dex.js:21:43
here is my dex.js
// connect to Moralis server
const serverUrl = "https://xiqxyv5bgozp.usemoralis.com:2053/server";
const appId = "7ZyhnEhnPqCPvyN7zLl4vNrymoTQ2YUJYiXOWf9y";
Moralis.start({ serverUrl, appId });
async function login() {
let user = Moralis.User.current();
if (!user) {
user = await Moralis.authenticate();
}
console.log("logged in user:", user);
}
async function logOut() {
await Moralis.User.logOut();
console.log("logged out");
}
document.querySelector("#btn-login").addEventListener('click', login);
document.getElementById("btn-logout").addEventListener(`click`, logOut);
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.1inch.exchange/v3.0/137/tokens');
const tokens = await response.json();
const tokenList = Object.values(tokens.tokens);
return tokenList.filter(token => tickerList.includes(token.symbol));
}
getTop10Tokens()
.then(getTickerData)
.then(console.log);