The getRating() JavaScript method provides information about the rating given to the currently open map or topic. It is only available in the Reader designer (with the map variable) and Topic template designer (with the topic variable).
Example
The following example prints the rating information in the user's browser console.
async function getTopicRatingAsync() {
try {
const ratingSummary = await topic.getRating();
console.log(JSON.stringify(ratingSummary, null, 2));
} catch (error) {
console.error('Error getting rating:', error);
}
}
// Call the function to rate the topic
getTopicRatingAsync();