Viewing infos of the member from custom Dataset

I used this code to retrieve the information of a member from a custom dataset but instead it is returning the same data in all member account. My intent is to return only the member data log in.
Need help please
import wixUsers from ‘wix-users’;
import wixdata from ‘wix-data’
$w.onReady( function () {
wixUsers.onLogin((user) => {
let userId = user.id; // “r5cme-6fem-485j-djre-4844c49”
let isLoggedIn = user.loggedIn; // true
if (wixUsers.currentUser.loggedIn) {
user.getEmail()
.then((email) => {
let userEmail = email; // “user@something.com
$w(“#MemberPlanDataset”).onReady(() =>
user.getMemberPlanDataset()
.then((MemberPlanDataset) => {
let UserPlan = MemberPlanDataset;
let Myemail = UserPlan.email;
if ((userEmail) === UserPlan.email) {
let MyPlan = UserPlan.Plan;
let MyPrix = UserPlan.Prix;
let MyStatut = UserPlan.Statut;
let MyValidite = UserPlan.validite;
} else {
$w(“#box18”).show();

          } 

        })); 
    }); 
} 

});
});

If you are trying to get the current user then use Wix Users API and it’s currentUser function in your code.
https://www.wix.com/corvid/reference/wix-users.html#currentUser

Once you have the members details, then you can query your custom dataset to get that members info from it and use it for whatever you need.

Thanks for the feedback, I used query to get the results but it still doesn’t give the infos of the member logged in.
below is the code, can you check it please? Thanks

import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
export function getUserDataByEmail(email) {
$w.onReady( function () {
wixData.query(“MemberPlanDataset”)
.eq(“loginEmail”, email)
.then((results) => {
let Myemail = email;
if (wixUsers.currentUsers.email === Myemail) {
wixUsers.getMemberPlanDataset()
.then((MemberPlanDataset) => {
let UserPlan = MemberPlanDataset;
let MyPlan = UserPlan.Plan;
let MyPrix = UserPlan.Prix;
let MyStatut = UserPlan.Statut;
let MyValidite = UserPlan.validite;
})

            }  **else**  { 
                $w("#box18").show(); 
            } 

        }); 
}); 

}

@yeobema

Quick reply as not on long, for starters your page onReady function needs to go underneath your imports with the export function underneath
https://www.wix.com/corvid/reference/$w.html#onReady

@givemeawhisky
thanks for the feedback, but this still doesn’t work, any tips!!!