dmikester1 – 18-12 Nov 23

I have this function in my React app that makes an api call that does some work that might take some time and I do not want to wait for it to finish.
const switchShifts = async () => {
console.log({ bagCounts });
const completedOrders = orders
.filter((o) => o.DATE_COMPLETED !== null)
.map((o) => {
return { orderID: o.ORDER_ID, GUID: o.ORDER_GUID };
});
completeOrdersInBC(completedOrders);
// more code to run down here without waiting for 'completeOrdersInBC'
...
};
const switchShifts = async () => {
console.log({ bagCounts });
const completedOrders = orders
.filter((o) => o.DATE_COMPLETED !== null)
.map((o) => {
return { orderID: o.ORDER_ID, GUID: o.ORDER_GUID };
});
completeOrdersInBC(completedOrders);
// more code to run down here without waiting for 'completeOrdersInBC'
...
};
D
dmikester1512d ago
But my IDE is complaining that it wants me to insert an 'await' in front of the 'completeOrdersInBC' call.
UU
Unknown User512d ago
D
dmikester1512d ago
Thank you! What if I want to await one call in that function, but not another?
UU
Unknown User511d ago