Get User data from Moralis DB for users who are not current user

Is it possible to query data from User by using their wallet address?

I didn’t see anything here: https://docs.moralis.io/moralis-dapp/users/current-user#security-for-user-objects

Basically I setup profile pages with custom fields for social links that are saved to each User that I want to query from each page. I need the email as well.

I guess I could make a new Profile class but then that doesn’t have the email adddress.

You can do it using the cloud function where you can query using master key to get the user data.

this is an example function which returns the rows with ethAddress

Moralis.Cloud.define("getUser", async (request) => {
  const query = new Moralis.Query("User");
  query.equalTo("ethAddress", request.params.ethAddress);
  const results = await query.find({
    useMasterKey: true,
  });
  return results;
});
1 Like

Perfect thank you!

I’ll have to lookup how to use the Cloud functions.