[react-moralis] useNewMoralisObject cannot save

Hi the following does not get saved. and no error is caught. After try/catch block I get error for getting id property of a null object

    try {
      await save(
        moralisThumbnail,
        title.toString(),
        parseFloat(price),
        category.toString(),
        desc.toString(),
        sellerId.toString()
      );
    } catch (error) {
      console.error("Failed to create new Object: ", error);
    }
    console.log("New created with: ", object.id);

The hook should return the error for you, as it is resolved and you don’t need to use try/catch. If you want to use custom error handling, you can provide throwOnError
See the docs:

and

1 Like