From 1b9b41ad6ed20acbd0318ce6962da5908cb922d3 Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Thu, 21 Nov 2024 21:10:25 -0300 Subject: [PATCH] fix(modules): Read order with primary preference for consistency after checkout --- .../firebase/functions-checkout/handle-order-transaction.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/modules/src/firebase/functions-checkout/handle-order-transaction.ts b/packages/modules/src/firebase/functions-checkout/handle-order-transaction.ts index da0685a24..3ff3525ab 100644 --- a/packages/modules/src/firebase/functions-checkout/handle-order-transaction.ts +++ b/packages/modules/src/firebase/functions-checkout/handle-order-transaction.ts @@ -15,13 +15,15 @@ const newOrder = async (orderBody: OrderSet) => { return new Promise<{ order: Orders | null, err?: any }>((resolve) => { setTimeout(async () => { try { - const order = (await api.get(`orders/${orderId}`)).data as Orders; + const { data: order } = await api.get(`orders/${orderId}`, { + headers: { 'x-primary-db': 'true' }, + }); resolve({ order }); } catch (err: any) { logger.error(err); resolve({ order: null, err }); } - }, 800); + }, 400); }); } catch (err: any) { if (err.message === 'fetch failed') {