Async function to call approve and get allowance before buy method

Hi everyone,

I'm starting to learn basic stuff like deploying contracts using remix, Nodejs, and so on; I'm following some examples of how to interact with contracts and buy tickets online, for a lottery, movies, and so on, and I found a good example, the part of the code that I'm having issues is when I try to call function to Buy the tickets since I need first call the approve function. Then the allowance of the token that is the only allowed to buy tickets, I'm using Metamask for signing the transactions.

Contract code:

/**
    function buyTickets(uint256 _lotteryId, uint32[] calldata _ticketNumbers)
        external
        override
        notContract
        nonReentrant
    {
        require(_ticketNumbers.length != 0, "No ticket specified");
        require(_ticketNumbers.length <= maxNumberTicketsPerBuyOrClaim, "Too many tickets");
      
        // Transfer cake tokens to this contract
        TokenContract.safeTransferFrom(address(msg.sender), address(this), amountToTransfer);

        // Increment the total amount collected for the lottery round
        _lotteries[_lotteryId].amountCollected += amountToTransfer
       
            // Increase lottery ticket number
            currentTicketId++;
        }

        emit TicketsPurchase(msg.sender, _lotteryId, _ticketNumbers.length);
    }

the index.js function

async function buytokens(){
    spender = $("#spender").val();
    amount = $("#amount").val();
    try{
      await TokenContract.methods.approve(lotteryAddress, amount).send({from:spender, gas: 10499964}).on('receipt',async function(data){
        console.log(data.events.Approval.returnValues);
        try{
          await TokenContract.methods.allowance(TokenContract._address, lotteryAddress)
          .call().then(async function(data){
            console.log(data);
            try{
              await lotteryContract.methods.buyTickets("1",[164746])
              .send({from:lotteryAddress, gas: 10499964}).on('receipt',async function(data){
                console.log(data.events.Approval.returnValues);
              })
            }
            catch(err){
              console.log(err);
            }
          })
        }
        catch(err){รง
          console.log(err);
        }
      });
    }
    catch(err){
      console.log(err);
      }
    }

the error is

MetaMask - RPC Error: Invalid parameters: must provide an Ethereum address.