I’m having troubles setting the data for a repeater.
I got this error: Wix code SDK error: Each item in the items array must have a member named _id
which contains a unique value identifying the item.
I checked this answer in the forum, but I don’t understand what I’m missing.
Any idea what’s the issue?
Hi,
can you also share the code you are using to set the items to repeater?
Thanks!
Sure.
This is it:
export function retrieveDataButton_click(event, $w) {
getPropertiesBundle()
.then(json => {
console.log(json);
var propertyBundle = json;
$w("#repeater1").data = propertyBundle;
for(let i=1;i<=propertyBundle.lenght;i++) {
$w("#repeaterPropertyTitle").text = propertyBundle[i].property.title;
$w("#repeaterPropertyAddress").text = propertyBundle[i].property.snippet;
};
});
}
I must add that I recover the data using wix http-function and get a json from a web-service:
import {fetch} from 'wix-fetch';
export function getPropertiesBundle() {
const url = 'http://myCensoredUrl
console.log("Url: " + url);
return fetch(url, {method: 'get'})
.then(response => response.json());
}
Had the same issue, fixed it.
For those wondering, the check that wix does for a missing “_id” property is not explicit. Probably done with a == instead of ===. Any _id of “0” is treated as the same as null or undefined . Adding a prefix to the _id will resolve the issue. Do note that property _id must be of type string .