Good afternoon dear Wix Community,
my site is connected to an external collection. I need to read out data which are stored as nested JSON objects in one column. The data I need to capture are called “price” and “availability” in the column “offers”. Reading through the Repeater literatury, I doubt that these data can be shown directly in a repeater due to missing unique IDs. I have written some code, pushing all my data in a separate array + adding IDs. The results are shown nicely in the console. log, but the textbox in the repeater becomes blank, when I start running the code. Any idea of what am I doing wrong here? Below is my code: Many many thanks for your support!
import wixData from 'wix-data';
$w.onReady(function () {
$w('#button1').onClick (() => {
const bookingNumber = parseInt($w('#input1').value, 10);
wixData.query("Hotel/Reservations")
.eq("resa_package_code", bookingNumber)
.find()
.then((results) => {
const filteredCombined = []
for(let i = 0; i < results.items[0].offers.length; i++) {
if (results.items[0].offers[i].departure_city=== null && results.items[0].offers[i].category === "Shared Rooms") {
let dataObject = {_id: i, price: results.items[0].offers[i].price, availability: results.items[0].offers[i].available_stock, };
filteredCombined.push(dataObject);
}
else {
}
}
console.log(filteredCombined);
$w('#repeater1').data = filteredCombined;
$w("#repeater1").forEachItem(($item, itemData, index) => {
$item("#text20").text = itemData.price;
});
})
.catch((err) => {
console.log(err)
throw new Error(err)
});
});
});
Below is the excerpt of the console: