I having this error (as I mention on my title post) with my dynamicDataset whereby I want to pass random data to dynamic page to display more detail about testimony stories.
Here I attach my $w.onReady() snippet
$w.onReady(() => {
$w("#dynamicDataset").onReady(async function () {
//Total testimony
wixData.query("Testimonial")
.count()
.then((results) => {
let counterTestimoni = results.toString();
$w("#totalCountTxt").text = String(counterTestimoni + " interesting stories");
})
//random featured story
randomStory();
//shuffle repeater
let data = $w("#testimonialRepeater").data;
data = shuffle(data);
$w("#testimonialRepeater").data = data;
//Load testimony
loadPrograms();
$w('#testimonialRepeater').show("float", floatInOptions);
});
});
And below is my snippet code for randomStory();
//random featured story
export function randomStory() {
wixData.query("Testimonial")
.find()
.then((results) => {
let randomNumber = Math.floor((Math.random() * results.items.length));
let randomItem = results.items[randomNumber];
$w("#text29").text = randomItem.tesName;
$w("#text30").text = randomItem.product;
$w("#image6").src = randomItem.tesProfilePic;
$w("#text31").text = randomItem.tesDescription;
if ($w("#text31").text.length > 100) {
$w("#text31").text = randomItem.tesDescription.substr(0, 100) + "...";
}
$w('#button2').link = "/testimonial-1/randomItem.tesName";
});
}
I hope anyone could help me what am I missing or what mistake did I do with my code.