Skip to content

Commit

Permalink
fix: stop accessing response text multiple times (#195)
Browse files Browse the repository at this point in the history
As text is a stream it can only be accessed once otherwise it would
error.
  • Loading branch information
Zangetsu101 authored Jul 9, 2024
1 parent dfc63d5 commit 7f3902d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/api/notification/sms-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 7f3902d

Please sign in to comment.