Damn! Canāt get this to work and must be missing somethingā¦
Back-endā¦
export async function get_AllUserData() {
let user = await wixUsersBackend.currentUser; console.log("USER: ", user)
let userID = await user.id; console.log("User-ID: ", userID);
let isLoggedIn = user.loggedIn; console.log("User-Logged-In: ", isLoggedIn);
let userEmail, userData;
user.getEmail().then((email)=> {userEmail = email; console.log(userEmail);});
user.getRoles().then((roles) => { console.log("Get roles...");
let userRole1 = roles[0]; console.log("User-Role-1: ", userRole1);
let userRole2 = roles[1]; console.log("User-Role-2: ", userRole2);
let roleTitle1 = userRole1.name; console.log("Role-Name-1: ", roleTitle1);
let roleTitle2 = userRole2.name; console.log("Role-Name-2: ", roleTitle2);
let roleDescription1 = userRole1.description; console.log("Role-Description-1: ", roleDescription1);
//$w('#txtLogin').text = userRole1.name;
userData = {
"userID" : userID,
"userEmail" : userEmail,
"userRole" : userRole1,
"roleID" : "roleID",
"roleTitle" : roleTitle1,
"roleDescription": roleDescription1
}
wixUsersBackend.getUser(userID)
.then((res) => {console.log(res)
userData.userLoginmail = res.loginEmail;
userData.userFirstname = res.firstName;
userData.userLastname = res.lastName;
userData.userNickname = res.nickname;
userData.userMembername = res.memberName;
// userData.userPicture = res.picture;
userData.userLanguage = res.language;
userData.userStatus = res.status;
userData.userSlug = res.slug;
userData.userEmails = res.emails;
userData.userPhones = res.phones;
userData.userLabels = res.labels;
userData.userCustomFields = res.customFields;
userData.lastLoginDate = res.lastLoginDate;
userData.creationdDate = res.creationDate;
userData.lastUpdateDate = res.lastUpdateDate;
console.log(userData);
return userData;
});
//return userData;
});
Normal call from front-endā¦
userData = await get_AllUserData(); console.log("USER-DATA-Load: ", userData);
Test in Back-End ist just fineā¦
But gets UNDEFINED on front-end for ā userData ā
userData = await get_AllUserData(); console.log("USER-DATA-Load: ", userData); //---> returns ---> UNDEFINED!š

By the way ā No ā I do not want to use two different functions, fired each from frontend and to get results back from backend.
(This way works ā but not my aim. I want it zipped in one functions). Possible?
What am i missing? Someone any idea?
I had a similar problem, but my fix was the await addition. Just for giggles⦠what happens (just for testing) if you introduce a delay after your await call and before the debug output? Maybe even something as silly as 10 seconds. Maybe for some reason the await is not working and the code is falling through. Not a fix, but a thought.
Thanks for your suggestion but without any luck.
I think, my issue will be the wrong placement of returns in my code, or not enought of them inside my code.
Ok, i will reply to myself xDDDD ā the first time 


Hello Velo-Ninja⦠try this oneā¦
import wixUsersBackend from 'wix-users-backend';
export async function get_AllUserData() {
let user = await wixUsersBackend.currentUser;
let userID = await user.id;
let isLoggedIn = user.loggedIn;
let userEmail = await user.getEmail();
let userRoles = await user.getRoles();
let userDetails = await wixUsersBackend.getUser(userID);
let userData = {
"userID" : userID,
"userEmail" : userEmail,
"userRoles" : userRoles,
"roleID" : "roleID",
"userState" : isLoggedIn,
// "roleTitle" : roleTitle1,
// "roleDescription": roleDescription1
}
userData.userLoginmail = userDetails.loginEmail;
userData.userFirstname = userDetails.firstName;
userData.userLastname = userDetails.lastName;
userData.userNickname = userDetails.nickname;
userData.userMembername = userDetails.memberName;
// userData.userPicture = userDetails.picture;
userData.userLanguage = userDetails.language;
userData.userStatus = userDetails.status;
userData.userSlug = userDetails.slug;
userData.userEmails = userDetails.emails;
userData.userPhones = userDetails.phones;
userData.userLabels = userDetails.labels;
userData.userCustomFields = userDetails.customFields;
userData.lastLoginDate = userDetails.lastLoginDate;
userData.creationdDate = userDetails.creationDate;
userData.lastUpdateDate = userDetails.lastUpdateDate;
return userData;
}
You do not need all the complicated and not really working code-examples from the VELO-API-DOCs anymore, when using this one 









Since i did not use ā then()-statements ā Async-Await is a ā> MUST!
If someone can show the same RESULT by using ā .then(()=>{}); ā
just put it under my own answer, and the ā BEST-ANSWER-AWARD ------------------------------------------------------> is YOURS !!! 















And just to proove my results on frontendā¦

So, what we have at the end?
Have fun
and happy coding!
Something like this:?
export async function get_AllUserData() {
await wixUsersBackend.currentUser
.then( (results) => {
return {
āuserIDā: results.userID,
āuserEmailā: results.userEmail,
āuserRolesā: results.userRoles[0].name,
āroleIDā: results.roleID,
āuserStateā: results.isLoggedIn
};
})
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
console.log(ā[get_AllUserData:]ā +āError detected:\nā+error.message);
});
I had some issues trying to figure out the methods/functions you are calling.
-
I am having some problems with what you have provided.
-
you are calling methods/functions but have not shown them.
(getemail(), getRoles(),getuser())
-
you have not shown what these do
-
are you returning the Object, eg: array, structure,
or are your functions extracting and returning a specific falue from the array/struture
Oops, there is a missing }, which has to be added to the end. This closes the export function line.
(NB: I did not run this code, but just looked at yours and consolidated and converted to a then() type method.
Nice try, but nope! 
-
Your job would have been, to get whole data of a current logged in user with one call from front-end.
You did not solve it
. ā All you get when running your code is ā
https://www.wix.com/velo/reference/wix-users-backend/currentuser
-
But the second part is missing completely ā
https://www.wix.com/velo/reference/wix-users-backend/getuser
To explain a little bit moreā¦
- You call with just one call from ā FRONT-END.
- Process starts on BACK-END and gets (whole) user-data (including)
https://www.wix.com/velo/reference/wix-users-backend/getuser
- After all data is collected, you give it back to FRONT-END (where you are waiting for your wished USER-DATA
.
And as i can see ā you also could not solve it, completely without usage of ā AWAIT.
BEST-ANSWER-AWARD will stay by me 




ā> NEXT-TRY! 
BTW: All you had to know isā¦
Normal call from front-endā¦
let userData = await get_AllUserData(); console.log("USER-DATA-Load: ", userData);
For your better imaginationsā¦
The shown code is already working on the following siteā¦
https://russian-dima.wixsite.com/login-system
You are correct. I had setup the example as reading data from a dataset. After looking at the API docs, it clearly shows that it does not use await. It seems that the API (which Iāve never used), looks to to be retrieving data from the users current session. But, the API documentation indicates that it returns a promise to return the information. Therefore, using an await, along with a then() is the preferred way, since you have to wait for the data (because of promise).
My goal wasnāt to provide the whole answer, just a framework on how to
proceed. Reading your existing backend code, I only returned the values you defined in your āuserDataā datastructure. Since all the other fields were not in the datastructure, I ignored them.