Skip to content

Commit

Permalink
Merge pull request #777 from egargan-ft/ELES-1237-fix-no-highlights-h…
Browse files Browse the repository at this point in the history
…andling

Fix automatic 'setIncludeHighlights' + handle errors from highlights token request (ELES-1237)
  • Loading branch information
egargan-ft authored May 14, 2024
2 parents 0f6cd28 + 9477365 commit 97b1bd9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion components/x-gift-article/src/SharingOptionsToggler.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const SharingOptionsToggler = (props) => {
actions.showAdvancedSharingOptions()
} else {
actions.hideNonSubscriberSharingOptions(event)
actions.setIncludeHighlights(event.target.checked)
}
return
}
Expand Down
6 changes: 6 additions & 0 deletions components/x-gift-article/src/lib/highlightsApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export default class HighlightsApiClient {
)

const response = await fetch(url, options)

if (!response.ok) {
throw new Error(`failed to fetch ${url}, received ${response.status}`)
}

const responseJSON = await response.json()
return responseJSON
}
Expand All @@ -62,6 +67,7 @@ export default class HighlightsApiClient {
if (!includeHighlights) {
return {}
}

return await this.fetchJson('/create-token', {
method: 'POST',
body: JSON.stringify({ articleId })
Expand Down

0 comments on commit 97b1bd9

Please sign in to comment.