From 935883bfa9a131c3e05efe9694e5d9b6fc65a22b Mon Sep 17 00:00:00 2001 From: Tameem Bin Haider Date: Fri, 5 Jul 2024 11:28:49 +0600 Subject: [PATCH] fix: stop accessing response text multiple times As text is a stream it can only be accessed once otherwise it would error. --- src/api/notification/sms-service.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/api/notification/sms-service.ts b/src/api/notification/sms-service.ts index a4d2016cb..caffde3bb 100644 --- a/src/api/notification/sms-service.ts +++ b/src/api/notification/sms-service.ts @@ -80,15 +80,13 @@ export async function sendSMS( } const responseBody = await response.text() - logger.info(`Response from Infobip: ${JSON.stringify(responseBody)}`) if (!response.ok) { - logger.error( - `Failed to send sms to ${recipient}. Reason: ${response.text()}` - ) + logger.error(`Failed to send sms to ${recipient}. Reason: ${responseBody}`) throw internal( - `Failed to send notification to ${recipient}. Reason: ${response.text()}` + `Failed to send notification to ${recipient}. Reason: ${responseBody}` ) } + logger.info(`Response from Infobip: ${JSON.stringify(responseBody)}`) } const compileMessages = async (