Save transaction hash for custom purchase table

I am following the Amazon clone video. Everything is working well. I’m trying to add a transaction hash field to the custom “Transaction” table. Currently for the table it is pulling the address “Customer” directly from Moralis. My other three fields, “Delivery”, “book.name”, “book.price”, are all custom fields not related to moralis api (i guess book.price is related somewhat).

I know the transaction hash is automatically saved for all transactions. I can see it in the “BscTransactions” table in the moralis dashboard. I feel like I shouldn’t have to run a query for something that is already being pulled by default and for something that just instantaneously happened.

Here is the full code:

import {Select, Button, Modal, Input} from 'antd'

import {ShoppingCartOutlined} from "@ant-design/icons";

import { useState } from 'react';

import { useMoralis } from 'react-moralis';

const {Option} = Select;

function Purchase({book}) {

  const [isModalVisible, setIsModalVisible] = useState(false);

  const [delivery, setDelivery] = useState("");

  const {Moralis, Native, account, chainId} = useMoralis();

  const handleOk = async () => {

    //Get token price on PancakeSwap v2 BSC

    const options = {

      address: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",

      chain: "bsc",

      exchange: "PancakeSwapv2",

    };

    const price = await Moralis.Web3API.token.getTokenPrice(options);

    const priceBNB = book.price / price.usdPrice;

   

    // Send Matic to book store owenr address

   

    const options1 = {

      type: "native",

      amount: Moralis.Units.ETH(priceBNB),

      receiver: "0xf435247364F38e7f182372fbfF58E50f0A90E88F"

     

    }

   

    let result = await Moralis.transfer(options1);

    //Save Transaction Details to DB

    const Transaction = Moralis.Object.extend("Transaction");

    const transaction = new Transaction();

   

    transaction.set("Customer", account);

    transaction.set("Delivery", delivery);

    transaction.set("Product", book.name);

    transaction.set("Spent", book.price);

    transaction.save()

    setIsModalVisible(false);

  }

i guess what i’m asking it to do is get the hash for the purchase that just happened (awaitMoralistransfer)

and then once i have that i can add it as a "transaction.set " item i assume

what do you have in that result?

thats the only place it says result. it is grayed out, indeed.

should i add result in the useMoralis section at the top?

I mean, to print it to see what value it has, you can use something like console.log(JSON.stringify(result))