Select Token To Swap video. swap is not working. javascript dex tutorial

hello everyone.

i decided too make new post with this issue. as my other issue is solved. im in the javascript dex tutoriol and my swap button is not working like in the video this is my code up too this point

<!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=""></script>
        <script src=""></script>

        <title>Moralis Dex </title>
        <link rel="stylesheet" href="style.css">




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




        <tbody class ="js-token-balances"></tbody>


    <form action="#" method="POST" class="exchange-form">
        <div class="form-row">


            <span class ="js-from-token"></span>
            <input type ="text" name="from-amount" class="js-from-amount" disabled  />

        <div class="js-amount-error error"></div>
        <div class="form-row">
            <button type="submit" class="js-submit" disabled > Get Qoute</button>
            <button class="js-cancel" disabled > Cancel</button>
        <div class="js-qoute-container"></div>

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

// connect to Moralis server

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

        .then ( () => console.log ('plugins have been initialized ') );

    const $tokenBalanceTBody = document.querySelector('.js-token-balances');
    const $selectedToken =document.querySelector('js-from-token');
    const $amountInput= document.querySelector('.js-from-amount');

    //Converting  from wei  using custom function 
    const tokenValue = (value, decimals) => (decimals ? value / Math.pow(10, decimals): value);

   // 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",
    document.querySelector(".js-token-balances").innerHTML += balances
        (token, index) => `
        <td> ${index + 1}</td>
        <td> ${token.symbol}</td>
        <td> ${token.amount}</td>
        <td> ${Moralis.Units.FromWei(token.balance, token.decimals)}</td>

            data-max="${tokenValue(token.balance, token.decimals)}"



  async function initSwapForm (event) {
    $selectedToken.innerText =;
    $selectedToken.dataset.address =;
    $selectedToken.dataset.decimals =;
    $selectedToken.dataset.max =;
    $amountInput.value = '';
    document.querySelector('.js-qoute.container').innerHTML = '';



for ( let $btn of  $tokenBalanceTBody.querySelectorAll('js-initSwapForm')) {


  async function buycrypto () { ();


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

  document.getElementById("btn-login").onclick = login;
  document.getElementById("btn-buycrypto").onclick =buycrypto;
  document.getElementById("btn-logout").onclick = logOut;

  async function getTop10tokens() {
    const response = await fetch(" ");
    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("");
    const tokens = await response.json();
    const tokenlist = Object.values(tokens.tokens);
    return tokenlist.filter((token) => top10Tokens.includes(token.symbol));
    .then((top10Tokens) => gettickerdata(top10Tokens))
.error {

    color: darkred;

does anyone have any suggestions too how too fix this?

does this have something to do with my swap button?

Do you get any errors? Which tutorial are you following? There should be a link to a finished project repo where you can compare your code.

i dont get any errors. its the 2021 javascript programming for blockchain developers

this is what it looks like

Thanks. Since this is a locked course I don’t have a frame of reference for what is going on and it looks like there’s no errors. You can post on the Moralis Academy Forum with your issue if you haven’t already.