[SOLVED] 400 and Invalid Function GetNFTs errors

I’m fairly new to interacting with blockchains so this could be something simple I’ve misunderstood, but I am getting 400 errors and ‘Invalid function: “getNFTs”’ errors. I’ve tried using some of the troubleshooting code samples posted on this forum to attempt to rule out an issue with my code but everything I’ve tried gives me the same errors. MetaMask connects and signs as I think it should.
Here’s the current code:

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

    <button id="btn-login">Moralis Login</button>
    <button id="btn-getnftbalances">Get NFT Balances</button>
    <button id="btn-logout">Logout</button>

      // connect to Moralis server
      Moralis.serverURL = "https://jok6y0o5mjko.usemoralis.com:2053/server";

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

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

      async function getNFTBalances() {
        const options = {chain: 'binance smart chain', address: '0x90099da42806b21128a094c713347c7885af79e2'};
        const nfts = await Moralis.Web3.getNFTs(options);

      // bind button click handlers
      document.getElementById("btn-login").onclick = login;
      document.getElementById("btn-logout").onclick = logOut;
      document.getElementById("btn-getnftbalances").onclick = getNFTBalances;


And here is the console output:

moralis.js:21917 POST https://jok6y0o5mjko.usemoralis.com:2053/server/functions/getNFTs 400
dispatch @ moralis.js:21917
ajax @ moralis.js:21924
(anonymous) @ moralis.js:22028
Promise.then (async)
request @ moralis.js:22022
run @ moralis.js:427
run @ moralis.js:353
value @ moralis.js:5278
getNFTBalances @ test2.html:38
moralis.js:24018 Uncaught (in promise) Error: Invalid function: "getNFTs"
    at handleError (moralis.js:22050)
    at async HTMLButtonElement.getNFTBalances (test2.html:38)
_construct @ moralis.js:24018
Wrapper @ moralis.js:24422
(anonymous) @ moralis.js:8462
ParseError @ moralis.js:8513
handleError @ moralis.js:22050
async function (async)
getNFTBalances @ test2.html:38

The server is on 0.0.244 and I’ve tried redeploying it a few times (and each time I’ve been changing my Server URL and Application ID in the code) but that doesn’t seem to help.

Hey @kyleacct

We already checking this problem. Please don’t reload the server now :man_mechanic:

Use chain: 'bsc' instead of chain: 'binance smart chain'


Update your server. Now it should work correctly :man_mechanic:

Cool, that works now, thank you! Have a great day

1 Like

I’m really new, I’m trying to make a version of the “how to create your first dApp” and am experiencing this 400 error - moralis.js:29317 POST https://yz6bb2bokgsb.usemoralis.com:2053/server/functions/getNFTs 400

Maybe I missed a cloud function setup? I don’t seem to have all the functions of Moralis.Web3API codes?

My code:

getUserNFTs = async () => {
console.log(‘get NFTs clicked’);
let nfts = await Moralis.Web3API.account.getNFTs();

Hey @FunnyGuy

Please make sure you are using the latest version. If the version update will not help - share the console error message

Yes, this is the most current version. I started on this project only 2 days ago.

below is the console error message:

moralis.js:29317 POST https://yz6bb2bokgsb.usemoralis.com:2053/server/functions/getNFTs 400

from logs it looks like it didn’t receive the right parameters.

you can set chain and address parameters when you are not authenticated for Moralis.Web3API.account.getNFTs

I’ve tried adding parameters, like chain and address, however it returns the same message with additional errors.

I tested now Moralis.Web3API.account.getNFTs with your server and it worked fine without any error, I also forced an error with an invalid chain

I’m still getting the error message.
What did your code look like?

looks like I needed to re-authenticate - thank you for the hint