dmikester1
dmikester12y ago

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'
...
};
4 Replies
dmikester1
dmikester12y ago
But my IDE is complaining that it wants me to insert an 'await' in front of the 'completeOrdersInBC' call.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
dmikester1
dmikester12y ago
Thank you! What if I want to await one call in that function, but not another?
reactibot
reactibot2y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1045039031492288572