Hi everyone
Here is my question :
After that the user clicks on the button “Profile”, I would like to redirect him either to “First connection” or “profile page” based on either his phone number is completed or not.
Here is a short view of the Members database (as you can see, there is multiple fields) :
Here is my code :
export function profileButton_click(event) {
let user = wixUsers.currentUser;
let userEmail;
user.getEmail()
.then( (email) => {
userEmail = email;
} );
console.log(userEmail)
wixData.query("Members")
.eq("mail", userEmail)
.find()
.then( (results) => {
let firstItem = results.items[0]
console.log(firstItem)
let fieldValue = firstItem.phone;
let fieldValue2 = firstItem._id;
console.log(fieldValue.length)
if (fieldValue.length !== 0) {
wixLocation.to(`/members/${fieldValue2}`)
} else {
wixLocation.to(`/members-first-connection/${fieldValue2}`)
}
})}
However, the object returned by the query is this one :
I understand that fieldvalue.length is undefined since firstItem.phone doesn’t exist in the object.
So here is my question :
Why the query doesn’t return all the fields that are on my database ? Am I missing anything ?
Thank you