Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix automatic 'setIncludeHighlights' + handle errors from highlights token request (ELES-1237) #777

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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