Cannot return value from function

Your code is perfect except one small error. So in .then() the response gives a return to wixData.query and not the main function i.e returnMemberData. You thus need to return wixData.query as well. Here is the code:


import wixData from 'wix-data';

export function returnMemberData(email) {

 return wixData.query("Members/PrivateMembersData")
 .eq("loginEmail", email)
 .limit(1000)
 .find()
 .then(results => {
 if (results.items.length > 0) {
                console.log("Results found")
 const myResults = results.items[0];
 //console.log("MyResults: " + myResults.firstName)

 const myUser = {
                    firstName: myResults.firstName,
                    lastName: myResults.lastName
 }
                console.log("MyUser: " + myUser.firstName)
 return myUser
 } else {
                console.log("No Results")
 }
 })
 .catch((err) => {
 let errorMsg = err;
            console.log("Error: " + errorMsg)
 });
}

I hope this was helpful.