Skip to content

Commit

Permalink
Update error handling in get audience
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-joshi99 committed Mar 8, 2024
1 parent f708118 commit b897052
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/destination-actions/src/destinations/klaviyo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,16 @@ const destination: AudienceDestinationDefinition<Settings> = {
const apiKey = getAudienceInput.settings.api_key
const response = await request(`${API_URL}/lists/${listId}`, {
method: 'GET',
headers: buildHeaders(apiKey)
headers: buildHeaders(apiKey),
throwHttpErrors: false
})

if (!response.ok) {
const errorResponse = await response.json()
const klaviyoErrorDetail = errorResponse.errors[0].detail
throw new IntegrationError(klaviyoErrorDetail, 'INVALID_REQUEST_DATA', response.status)
}

const r = await response.json()
const externalId = r.data.id

Expand Down

0 comments on commit b897052

Please sign in to comment.