Skip to content

Commit

Permalink
fix: don't fetch highlights token when no highlights present
Browse files Browse the repository at this point in the history
  • Loading branch information
egargan authored and egargan-ft committed May 13, 2024
1 parent 0f6cd28 commit 30599fe
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 30599fe

Please sign in to comment.