In the last forum I talked about the change of the rating on each repeater
I want to know if this code right or wrong
import wixData from 'wix-data';
import wixWindow from 'wix-window';
let profesores;
$w.onReady(async function () {
$w("#repeater1").forEachItem(($item, itemData, Index) => {
profesores = $w('#dynamicDataset').getCurrentItem();
initReviews();
});
async function initReviews() {
await $w('#Reviews').setFilter(wixData.filter().eq('profesoresId', profesores._id));
loadStatistics();
}
async function loadStatistics() {
const stats = await wixData.get('review-stats', profesores._id);
if (stats) {
let avgRating = (Math.round(stats.rating * 10 / stats.count) / 10);
let percentRecommended = Math.round(stats.recommended / stats.count * 100);
let ratings = $item('#generalRatings');
ratings.rating = avgRating;
ratings.numRatings = stats.count;
$item('#generalRatings').show(); }
}
$item('#generalRatings').show();
})
The only the problem is when I write this code I found an error that $item is not defined.
Thank you for your respond in the last forums
Eyad