Hello.every one . I have build a module to work with userdata i need to return only with username in case he login else return with error or any other message
this is my module
import wixUsers from ‘wix-users-backend’ ;
import wixData from ‘wix-data’ ;
var username ;
export async function CheckUsername () {
let user = wixUsers . currentUser ;
let userId = user . id ;
let isLoggedIn = user . loggedIn ;
let userdata = wixUsers . getUser ( userId );
let steamIDJSON = userdata
. then (( steamIDJSON ) => {
username = ( steamIDJSON . memberName );
// console.log(username);
});
return username ;
}
console with log print user name and works perfect while return back with returned with undefined
despite username is gloable variable
where is the error comes from ?