React-Moralis object

Code:
Moralisobject_Error

Error:

How to create moralis object in React?

Hi,

I ran the code and it seems to work properly.

The code I used to run it -

 import { useMoralis } from 'react-moralis';
 const { Moralis } = useMoralis();

 const Item = Moralis.Object.extend("Malik");
 const item = new Item();
 item.set("name", "bob")
 item.set("description", "bob is a man");
 await item.save(); 
 console.log(item);

Let me know if it worked for you or was there any import issue from your side.

Thanks.

Still getting the same error

what you get if you execute console.log(Moralis) ?

I fixed it using the following code:

const { save } = useNewMoralisObject(β€˜Item’);

await save({

     'name':filename,

     'description':description,

     'nftFilePath':nftFilePath,

     'nftFileHash':nftFileHash,

     'nftFileMetaDataPath':nftFileMetaDataPath,

     'nftFileMetaDataHash':nftFileMetaDataHash,

     'nftId':nftId,

     'nftContractAddress':TOKEN_CONTRACT_ADDRESS,

    });
2 Likes