This is how the client of this API dispatches a shipment:
// client/src/modules/shipment/services/dispatch-shipment.ts import { instance } from " @modules/app/modules/http/domain/instance " ; import { DispatchShipmentDTO } from " ../dto/write/dispatch-shipment " ;
export async function dispatchShipment ( props : DispatchShipmentDTO , ): Promise < boolean > { try { await instance . post ( " /shipments/dispatch " , props );
return true ; } catch { return false ; } }
Enter fullscreen mode
Exit fullscreen mode
And this is how it is consumed, in the button component:
// client/src/modules/shipment/components/DispatchButton/hooks/useDispatchButton.tsx const dispatched = await dispatchShipment ({ shipmentId , carrierId });
if ( ! dispatched ) { toastError ({ en : " The shipment could not be dispatched. " , es : " No se pudo despachar el envío. " , }); }
Enter fullscreen mode
Exit fullscreen mode
This code is not a bug, and reviewed on its own there is nothing to fix.…