Facing issues with onSuccess and onComplete - What is it used for?

Iā€™ve been trying to call two transactions - Second one only after the first transaction is ā€œCONFIRMEDā€. I tried to use onSuccess and onComplete, but both fires immediately after the transaction is ā€œSENTā€ and does not wait for the first transaction to get confirmed. Since my second transaction depends on the first one, I was never able to successfully complete both the transactions. I also donā€™t understand the difference between them as both seems to function in the same way.

Iā€™ve stuck for 3 days in a row. I went through the forum for related queries but did not find anything useful or it does not work. Any solution would be helpful for me.

What are you using? React, vanilla js, what function?

You can also use web3 or ethers directly

Iā€™m using ā€˜react-moralisā€™ module. (useWeb3Contract hook)

runContractFunction({
            params: {...},
            onSuccess: (results) => {...print the result...and then execute the next runContractFunction..},
            onError: (error) => {..print the error..}
})

Yeah, I could use Web3 directly, but then in which scenario should I use onSuccess and onComplete?