Reputation: 1
I am experiencing issues populating wix API fetched data to a repeater, though i did follow some example here i get an error, not sure why...
Link to a example: Wix: Populate repeater with external API call
here is the 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.
Wix code SDK Warning: The data that was passed to data contained at least two items with the same ID: . Only the first item was accepted.
my current code
import {getCurrentTemp} from 'backend/serviceModule';
//...
export function buttonFetch_click(event, $w) {
getCurrentTemp($w("#emailInput").value)
.then(CurrentTemp => {
// add an _id property to each object
CurrentTemp.forEach(item => item._id = item.id)
// feed the data to the repeater
$w('#repeater1').data = CurrentTemp;
} );
}
export function repeater1_itemReady($item, itemData, index) {
$item("#textResults").text = "Name: " + itemData.Title + "\n"
+ "Symbol: " + itemData.BreachDate + "\n"
+ "Rank: " + itemData.Description + "\n"
+ "Price (USD): " + itemData.DataClasses;
}
Upvotes: 0
Views: 1152
Reputation: 126
Each item must have unique id.
Install uuid
here https://support.wix.com/en/article/corvid-managing-external-code-libraries-with-the-package-manager
and setup id for each item
import uuid from 'uuid';
// .....
$w('#repeater1').data = CurrentTemp.map((item) => {
item._id = uuid();
return item;
});
// .....
Upvotes: 0