Wix code SDK error: The value of rating parameter

Hi, all!

I’m trying to include a ratings and reviews element to my product page following this tutorial (https://support.wix.com/en/article/velo-tutorial-adding-ratings-and-reviews-to-a-wix-stores-site)

There’s an error that pops up regarding my ratings display and percent of reviewers who recommend the product.

The error message

“root”: {

“insertId”:“…8gaEMp8CO2pdg254zx8bvs”
“timestamp”:“2022-01-21T21:26:36.271Z”
“severity”:“ERROR”

“labels”: { “siteUrl”:“https://www.happylittlefungi.com
“namespace”:“Velo”
“tenantId”:“9162657c-b8b0-4c50-9bcb-a5b669fa4269”
“viewMode”:“Site”
“revision”:“1225”
}

“operation”: { “id”:“…AyD_AvrZO30cFAfPyMnnck”
“producer”:“/product-page/minitub-mushroom-grow-kit”
“first”:false
“last”:false
}

“sourceLocation”: {}

“jsonPayload”: { “message”:“Wix code SDK error: The value of rating parameter that is passed to the rating method cannot be set to the value “0.8”. It must be between 1 and 5. n@ @ y@ rating@ @https://bundler.wix-code.com/9162657c-b8b0-4c50-9bcb-a5b669fa4269/21b1b2e6-7f8f-4557-9e6c-ba9424785ac2/2e4eae04-c6bc-405a-9aa2-4d9afb2533d2/pages/huunx.js?wix-data-as-namespace=true&replace-console=true&dependencies-token=3938:1:2219 l@ @ s@https://bundler.wix-code.com/9162657c-b8b0-4c50-9bcb-a5b669fa4269/21b1b2e6-7f8f-4557-9e6c-ba9424785ac2/2e4eae04-c6bc-405a-9aa2-4d9afb2533d2/pages/huunx.js?wix-data-as-namespace=true&replace-console=true&dependencies-token=3938:1:1234 u@https://bundler.wix-code.com/9162657c-b8b0-4c50-9bcb-a5b669fa4269/21b1b2e6-7f8f-4557-9e6c-ba9424785ac2/2e4eae04-c6bc-405a-9aa2-4d9afb2533d2/pages/huunx.js?wix-data-as-namespace=true&replace-console=true&dependencies-token=3938:1:1438 promiseReactionJob@[native code]”
}
“receiveTimestamp”:“2022-01-21T21:26:40.004Z”
}

Here is the code:

async function loadStatistics ( ) {
const stats = await wixData . get ( ‘review-stats’ , product . _id );
if ( stats ) {
let avgRating = ( Math . round ( stats . rating * 10 / stats . count ) / 10 );
let percentRecommended = Math . round ( stats . recommended / stats . count * 100 );
let ratings = $w ( ‘#generalRatings’ );
ratings . rating = avgRating ;
ratings . numRatings = stats . count ;
$w ( ‘#recoPercent’ ). text = ${ percentRecommended } % would recommend ;
$w ( ‘#generalRatings’ ). show ();
} else {
$w ( ‘#recoPercent’ ). text = ‘There are no reviews yet’ ;
}
$w ( ‘#recoPercent’ ). show ();
}

Can anyone help me understand where the error is and how to fix it?

Thanks in advance!