[SOLVED] Problem with Moralis.Web3API.storage.uploadFolder(options);

Hello,

   I am using React, and follow the example:
import React from "react";
import { useMoralisWeb3Api } from "react-moralis";

const Web3Api = useMoralisWeb3Api();

const uploadFolder = async () => {
  const options = {
    abi: [
      {
        path: "moralis/logo.jpg",
        content:
          "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3",
      },
    ],
  };
  const path = await Web3Api.storage.uploadFolder(options);
  console.log(path);
};
 But I got error:  "Expected 0 arguments, but got 1" for function Web3API.storage.uploadFolder. I found that there is no arguments in that function in Moralis package, 
  static storage: {
    uploadFolder: () => Promise<operations["uploadFolder"]["responses"]["200"]["content"]["application/json"]>;
  }
 My version is [email protected]

 What should I do now? Could you give me a updated example? Thank you

What version of react-moralis are you using ?

[email protected]

Do you have any idea?

I also tried uploadfolder using useMoralis()

const { Moralis } = useMoralis()
await Moralis.Web3API.storage.uploadFolder(options)

The error is same: Expected 0 arguments, but got 1

Looks like a type issue. You can patch the library e.g. for the hook, in the node_modules\react-moralis\lib\hooks\core\useMoralisWeb3Api\useMoralisWeb3Api.d.ts file you can add options:

storage: {
        uploadFolder: (options) => Promise<{

Thank you. It works in my local environment.

But it deploy it to server (like vercel), problem still exists. Hope library fixed in future :slight_smile:

Yes you would need to patch the change when you deploy (otherwise Vercel just installs react-moralis as it is currently) e.g. you could use something like patch-package.