[SOLVED] Uncaught (in promise) ReferenceError: object is not defined gettickerdata dex.js:52:23

hello everyone again

i have a new error that i cant figure out. im still in the dex javascript tutorial. i get the following error when i run my code

Uncaught (in promise) ReferenceError: object is not defined



this is my current code

     // connect to Moralis server

      const serverUrl = "******************";
      const appId = "***************";
      Moralis.start({ serverUrl, appId });

     // add from here down
     async function login() {
      let user = Moralis.User.current();
      if (!user) {
        user = await Moralis.authenticate();
      console.log("logged in user:", user);

    async function getStats()
      const balances = await Moralis.Web3API.account.getTokenBalances({chain:'polygon'});
      console.log (balances);


    async function logOut() {
      await Moralis.User.logOut();
      console.log("logged out");

    document.getElementById("btn-login").onclick = login;
    document.getElementById("btn-logout").onclick = 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 <= 10).map(token => token.symbol);


async function gettickerdata() {
    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));



<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <!-- Moralis SDK code -->
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
        <script src="https://unpkg.com/[email protected]/dist/moralis.js"></script>

        <title>Moralis Dex </title>


    <button id="btn-login">Moralis Login</button>
    <button id="btn-logout">Logout</button>

    <script src="./dex.js"></script>


does anyone have any suggestions on how too fix this? im following the video exactly and im not sure what im doing wrong

what is the exact line that gives that error?

its saying const tokenlist = object.values(tokens.tokens); is giving me the error

this is also giving me error

that error says that object is not defined, maybe is a typo? maybe it should be: Object.values

after i make it Object. values it throws the next line of code as a error

return tokenlist. filter(token => tickerlist.includes(token.symbol));

what is the error?

you can also add some logging with console.log to see what is there

Uncaught (in promise) ReferenceError: tickerlist is not defined

it looks like a typo tokerlist instead of tokenlist

1 Like

Here’s a little fix to this

async function getTop10tokens() {
  const response = await fetch(" https://api.coinpaprika.com/v1/coins ");
  const tokens = await response.json();

  let result = tokens
    .filter((token) => token.rank <= 10)
    .map((token) => token.symbol);

  return result;

async function gettickerdata(top10Tokens) {
  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) => top10Tokens.includes(token.symbol));

  .then((top10Tokens) => gettickerdata(top10Tokens))

@qudusayo that worked. I really appreciate the help :slight_smile: :blush: