Basically i am able to fetch data from and API but then displaying in a repeater is an issue considering that it comes in (groups of data) and i am not able to display in a repeater. Repeater is needed here coz several results can be found and i though repeater is gonna be the best option to display. Please check my code closely cox there might be an error i am newbie…
Erorr message:
Loading the code for the Check page. To debug this code, open fnaox.js in Developer Tools.
Wix code SDK error: Each item in the items array must have a member named `_id` which contains a unique value identifying the item.
Check
Line 18
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.
Check
Line 18
Wix code SDK error: Each item in the items array must have a member named `_id` which contains a unique value identifying the item.
Check
Line 18
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.
Here is the front end code:
//Form's page 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;
} );
}
$w.onReady(function () {
$w("#repeater1").forEachItem( ($item, itemData, index) => {
if(itemData.text){
$item("#textResults").text = + itemData.Title+ "\n"
+ "Name: " + itemData.BreachDate + "\n"
+ "Symbol: " + itemData.Description + "\n"
+ "Rank: " + itemData.DataClasses + "\n";
}
else {
$item("#textResults").text = "No way!";
}
} );
} );
Backed, i dont thin if there is any issue here
//serviceModule.jsw
import {fetch} from 'wix-fetch';
export function getCurrentTemp(inputemail) {
const url2 = "https://haveibeenpwned.com/api/v3/breachedaccount/"+inputemail+"?truncateResponse=false";
return fetch(url2, {method: 'GET',
headers: {
"Accept": "application/json",
'Content-Type': 'application/json',
'hibp-api-key':'xxxxxxxxxxxx'
} })
.then(response => response.json());
}
@Yisrael (Wix)
@givemeawhisky
Assist plz!