Include database transaction(await) with external process

Hi! How to make module Database.beginTransaction await external process.

Example: I have a this code:

const trx = await Database.beginTransaction()

...

await CompartmentOpening.create({
        id: uuid(),
        idBusiness: auth.user.id,
        status: 1,
        idCompartment: delivery.toJSON().idCompartment,
        idDelivery: idDelivery
      }, trx)

await post(`${url}`, {
            body: {
                ...data
            },
            headers: {
              'Content-Type': 'application/json'
            }
          })

await trx.commit()

How to join post method with trx await, for do not crash trx process ?

If function post method timeout, trx crash.

1 Like

Hi @mauriciolucas22

You can try - catch or .then() .catch() request and then deal with different scenarios based on caught error