Skip to content

Commit

Permalink
Merge pull request #786 from adobecom/MWPW-157845
Browse files Browse the repository at this point in the history
MWPW-157845: Fixed no aggregated rating message
  • Loading branch information
Blainegunn authored Sep 5, 2024
2 parents 27f2577 + 47d96f3 commit 8436328
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions acrobat/blocks/rnr/rnr.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,19 @@ function loadRnrData() {
};

return fetch(`${RNR_API_URL}/reviews?assetType=ACROBAT&assetId=${metadata.verb}`, { headers })
.then(async (result) => {
if (!result.ok) {
const res = await result.json();
.then(async (response) => {
if (!response.ok) {
const res = await response.json();
throw new Error(res.message);
}
return result.json();
return response.json();
})
.then(({ aggregatedRating }) => {
.then((result) => {
const { aggregatedRating } = result;
if (!aggregatedRating) {
window.lana?.log('No aggregated rating found for this assset.');
return;
}
rnrData.average = aggregatedRating.overallRating;
rnrData.votes = Object.keys(aggregatedRating.ratingHistogram).reduce(
(total, key) => total + aggregatedRating.ratingHistogram[key],
Expand Down

0 comments on commit 8436328

Please sign in to comment.