R
Reactiflux

help-js

dmikester1 – 18-12 Nov 23

Ddmikester111/23/2022
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'
...
};
But my IDE is complaining that it wants me to insert an 'await' in front of the 'completeOrdersInBC' call.
UUUnknown User11/23/2022
Message Not Public
Sign In & Join Server To View
Ddmikester111/23/2022
Thank you! What if I want to await one call in that function, but not another?
UUUnknown User11/24/2022
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!