How to fetch username without delay?

Hi! I’m trying to fetch the username with user.get("username") and read in a previous post that it’s an initial delay before fetching the data, hence the null value. I have a navigation component where I’m trying to fetch the username for a cloud function but every time I log in, it throws a null error and I need to refresh the page for it to initialize.

async function getUserData(){

      const params={"username": user.get("username")}

      const result = await"getUserProfile",  params)


      console.log("result", result)


Is there a workaround that could solve this issue? Any help would be appreciated!

is this in vanilla js or something else?

this also would get current user:

 query = new Moralis.Query("User");
 result =  await query.find()

Hi! No, it’s react js.Thank you for the reply :smiley:Your suggestion gave me the idea to try this Moralis.User.current().attributes.username which works perfectly… Best regards!