why isn’t this working???
// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import wixData from ‘wix-data’;
import wixUsers from ‘wix-users’;
$w.onReady(function () {
let user = wixUsers.currentUser;
let email = user.getEmail();
console.log(email);
wixData.query("Listings")
.eq("email",email)
.find()
.then((results) => {
console.log(results.items);
$w("#table1").rows = results.items;
});
});
You are not waiting for the getemail to be resolved (it´s an async proces). Use:
user.getEmail()
.then((rsemail) => {
userEmail = rsemail;
etc.
and put the query inside the .then((rsemail), so it will only be executed if the email has been resloved.
What am I doing wrong with this code? I want to filter results from a collections “email” field that matches the current logged in users email. No errors show but it won’t filter and displays entire collection.
import wixData from ‘wix-data’;
import wixUsers from ‘wix-users’;
$w.onReady(() =>{
let user = wixUsers.currentUser;
let email = user.getEmail();
wixData.query(“PostBids”)
.eq(“email”, email)
.find()
.then(() => {
$w(“#dataset1”).setFilter( wixData.filter()
.eq(“email”, email) );
});
});