I saw before the last post, but following the first post you sent me I changed my code. Still having an error although it’s a different one than before
ERROR MESSAGE: Wix code SDK error: The data parameter that is passed to the data method cannot be set to the value . It must be of type array
Now you can modify first the DATA, before push it into REPEATER!
When you understood this, you will be able work with distinct.
Take a look one more time, what are the results after DISTINCT ?
After the DISTINCT-PROCESS the DATA has not the right FORMAT anymore to be add to the REPEATER. You have first to modify it → creating an OBJECT.
How to do that, you will find in the link given above.
Unfortunately I have the same error message as the last one. Probably it’s because of some stupid error I have in my code. To be honest, the last part added by you and Yisrael looks like the moon to me
// For full API documentation, including code examples, visit https://wix.to/94BuAAs
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
import { session } from 'wix-storage';
let userEmail;
let userId;
let titnomcirc
$w.onReady(function () {
wixData.query("Members/PrivateMembersData")
.eq("_id", wixUsers.currentUser.id)
.find()
.then((results) => {
userEmail = results.items[0].loginEmail;
userId = results.items[0]._id;
$w('#text72').text = userEmail;
});
titnomcirc = session.getItem("flagcircuito");
$w('#nomcirc').text = titnomcirc
//cCODE UPDATED
$w.onReady(function () { myFunction() });
function myFunction () {
wixData.query("clubbitComcategprod")
.distinct("nomcateg")
//.find()
.then((results) => {
if (results.items.length > 0) {
let items = results.items;
let firstItem = items[0];
let length = results.length;
let query = results.query;
console.log(length)
console.log(items)
console.log(firstItem)
console.log(query)
let myNewData = []
for (var i = 0; i < results.items.length; i++) {
myNewData.push({"_id": items[i]._id, "message": items[i].message
});
}
$w('#repeater1').data = [];
$w('#repeater1').data = myNewData;
$w("#repeater1").onItemReady(($item, itemData, index) => {
$item("#text71").text = itemData.nomcateg;
})
} else {}
})
.catch((error) => {
let errorMsg = error.message;
let code = error.code;
});
}
})
DO NOT USE onReady more then ONCE!
You make the same errors ^^
There were some little bugs in the code.
Perhaps you will have to improve and to modify it a little bit.
I deleted the repeater-function.
First let this part work. After you have got it to work, you can do the second step.
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
import { session } from 'wix-storage';
let userEmail;
let userId;
let titnomcirc
$w.onReady(function () {
wixData.query("Members/PrivateMembersData")
.eq("_id", wixUsers.currentUser.id)
.find()
.then((results) => {
userEmail = results.items[0].loginEmail;
console.log(userEmail)
userId = results.items[0]._id;
console.log(userId)
$w('#text72').text = userEmail;
});
titnomcirc = session.getItem("flagcircuito");
$w('#nomcirc').text = titnomcirc
{ myFunction() });
})
function myFunction () {
wixData.query("clubbitComcategprod")
.distinct("nomcateg")
//.find()
.then((results) => {
if (results.items.length > 0) {
let items = results.items;
let firstItem = items[0];
let length = results.length;
let query = results.query;
console.log(length)
console.log(items)
console.log(firstItem)
console.log(query)
let myNewData = []
for (var i = 0; i < length; i++) {
myNewData.push( {"_id": items[i]._id, "message": items[i].message} )
});
console.log(myNewData)
}
else { }
});
.catch((error) => {
let errorMsg = error.message;
let code = error.code;
});
});
Take a carefuly look onto all CONSOLE-LOGS when CODE is running.
OK! Tomorrow i will reconstruct that shit xDDDDDD.
Now i want to know whats that shitty problem. @Yisrael, perhaps he sees this post and has a good advise.
My ideas going out xD.
I have to test it on my own then, if nothing else works.
But now is time to go to bed!
I go sleep and you work on it. When i come back, everything works! xDDDD
See ya!
@noanest
Everything ok, you know women are not the best in technical things .
Oh my, i hope i will not killed tomorrow , because of this sentence xD.
Yeah, i did not expect that, this turns into a bigger working project, but i already said YES, so just go truth and DO IT ! (surely my last time xD)
Yes i know what you mean on this part oc code.
I hope i could make it a little bit more understandable on my site in the given example.
let myNewData = []for (var i = 0; i < results.items.length; i++) { myNewData.push({"_id": items[i]._id, "message": items[i].message
Good luck with your further projects.
When you have spent about 6-Month on this forum (day by day), you will also be able understand a little bit more then now .