Unable to view ratings display

I have used the tutorial: https://support.wix.com/en/article/corvid-tutorial-capturing-and-displaying-ratings to display live ratings on my website; however, the ratings have not displayed. I looked through the console and I do not receive errors in the code itself.

console code:
export function ratingsInput1_change(event) {

$w("#dataset1").onReady(() => { 

// get the current item from the dataset
const currentItem = $w(“#dataset1”).getCurrentItem();

// get the current average rating, number of ratings, and
//total ratings for the current dataset item
const average = currentItem.avg;
const count = currentItem.numRatings;
const total = currentItem.totalRatings;

// get the new rating from the ratings input
const newRating = $w(‘#ratingsInput1’).value;

// calculate the new average rating based on the current
//average and count
const newAverageLong = (total + newRating) / (count + 1);
// Round the average rating to 1 decimal point
const newAverageShort = Number.parseFloat(newAverageLong).toFixed(1);

// set the dataset fields to the new average, total
// ratings, and number of ratings
$w(‘#dataset1’).setFieldValues({
‘avg’: newAverageShort,
‘totalRatings’: total + newRating,
‘numRatings’: (count + 1)
});

// save the dataset fields to the collection
$w(‘#dataset1’).save()
. catch ((err) => {
console.log(‘could not save new rating’);
});
});
}

Though the ratings do not display on the website, I do not see anything getting reported through the data sheet.

bump

See these two examples to see how to build a Ratings system:

BTW - you only need a dataset onReady() handler in the page’s onReady() function, and only when you intend on using the dataset in the page’s onReady() function.

So, do I not need that? I may not understand fully since I am relatively new to code.

See the documentation for the dataset onReady() .

Does this mean I need to replace anything that I have already or do I just add this code at the bottom of what I already have?

Remove the dataset’s onReady() in the ratingsInput1_change() function.

I’m not sure if that’s the problem or not. Refer to the examples to see how to handle ratings.

Ratings
Ratings by Users

Thanks! Taking that out worked out. The data is being collected; however, the ratings aren’t displaying on the site. Is there a delay or is there something I am missing in the code? perhaps in the collection itself…

How are you trying to displaying the rating?

See the examples in the links to see how to save and display ratings.