Open your MASTER-PAGE and add the following into it…
MASTER-PAGE-CODE:
import wixMembers from 'wix-members';
$w.onReady(async()=>{console.log("Master-Page running...");
//-----On-Login-Section-----------------------------------
wixMembers.authentication.onLogin(async(member)=> {
console.log("MEMBER: ", member);
let memberData = await member.getMember();
console.log('MEMBER-Data: ', memberData);
const memberRoles = await member.getRoles();
console.log('MEMBER-ROLES: ', memberRoles);
const memberID = memberData._id;
console.log('MEMBER-ID: ', memberID);
const memberProfile = memberData.profile;
console.log('MEMBER-PROFILE: ', memberProfile);
const memberDetails = memberData.contactDetails;
console.log("MEMBER-DETAILS: ", memberDetails);
memberData.memberID = memberID;
memberData.memberRoles = memberRoles;
memberData.memberBadges = memberBadges;
//----------------------------------------------------
console.log('FINAL-MEMBER-DATA: ', memberData);
});
So normaly you even do not need to set it up on backend, because you can get almost all needed MEMBER-INFO also directly on FRONTEND after the user has logged-in.
But if you sill want to use your way…
$w.onReady(async()=>{console.log("Master-Page running...");
//-----On-Login-Section-----------------------------------
wixMembers.authentication.onLogin(async(member)=> {
............your code here to call the backend-function...................
});
});