- Create a JSW-Backend-file.
- Paste this code to the created back-end-file…(call it like you want —> USER )
import wixUsersBackend from 'wix-users-backend';
export function getUser(userID) {
return wixUsersBackend.getUser(userID)
.then((userData) => {
return userData;
});
}
- Paste this code to front-end…
import { getUser } from 'backend/USER.jsw'
$w.onReady(async()=>{
$w('#myButton).onClick(()=>{
let myUserData = await getUser(userID); concole.log(myUserData)
});
});
Of course you have first to get the USER-ID!
Were you able to solve your issue?
@russian-dima ThankYou for Your Great Help( But There Is An error in the front end code ’ Cannot find name ‘userID’. on this area ( let myUserData = await getUser ( userID ); )
Parsing error: Cannot use keyword ‘await’ outside an async function
‘await’ expressions are only allowed within async functions and at the top levels of modules.
save operation failed: DatasetError: Some of the elements validation failed
@sougandhr
My fault!
Place the ASYNC like following…
$w.onReady(()=>{
$w('#myButton).onClick(async()=>{
let myUserData = awaitgetUser(userID); concole.log(myUserData)
});
});
@russian-dima ThankYou for reply,Async Problem Solution Worked ,but still ’ Cannot find name ‘userID’.
on this area
( let myUserData = await getUser ( userID ); )
@sougandhr
Of course you have first to add an ID, before you can get User-Details of wished user-ID.
Replace → “userID” with one existing USER-ID of your DB.
$w.onReady(()=>{
$w('#myButton).onClick(async()=>{
let userID = "138869651346450264582" //<-- put in here your ID
let myUserData = await getUser(userID); concole.log(myUserData)
});
});
@russian-dima ThankYou For Your Help
@sougandhr
Could you solve your issue ?
How can i specify that i only need loginEmail
No problem already solved it:joy:

Not recommended to bump-up old posts like this one!
WHY ???
Because you will follow old and depricated stuff. Just like you already doing right now!!!
Wix-Users-API is an OLD and DEPRICATED-API !!!
Using on your own risk !!!
Instead use a newer API called → Wix-Member(s) !
Never bump-up old posts → instead open your own one and describe your issue!
This post is already about 2-years old!