Send user object in request from JS console in dashboard

Hello,

I’m trying to pass the user in the cloud function request call in JS console in dashboard as I don’t have the client to create the user using useMoralis().
However, when using JS console, then the user being passed is undefined. How should I pass the user in the request from JS Console?

As a sample: I’m doing it like this:

const user = "0x423b44fee143fc5626948275b4061fec79c20ac7" // EOA eth address
const chain = "0x4" //request params
const type = "core" //request params
const res = await Parse.Cloud.run("createVault", {chain, type}, {user})

Hi @deepanshu,

We have to pass the query arguments in the second argument of the function. Please try this -

const res = await Parse.Cloud.run("sendWelcomeEmail", {chain, type, user});

Hope this helps. :smiley:

Hi @malik,

I actually want to use request.user field provided by Moralis and not the request.params.user.

The way you suggested would only work with request.params.user, However I want to make it work for request.user so that I can get the user details who has called this function.

If I get it right on what you want to do (as in test with a user that you don’t have his wallet address), you can create a separate cloud function that accepts different parameters in order to obtain the user object.

I do have the crypto wallet address of the user (0x423b44fee143fc5626948275b4061fec79c20ac7) and my main concern is:

  1. How to pass the user in the Moralis request (specifically if there is no client and want to test the API from backend by the mocking the user)
  2. How to use request.user inside the cloud function?

Could you please assist me to solve this problem:

  1. How can I use requireUserKeys based on Moralis in-built request.user on the server side`?
  2. How to get the Users linked to the Roles (under in-built class “_Role”)?

Can you provide some sample codes?

I’m trying something like this but not able to get the user linked to the specific role.

const roleQuery = new Moralis.Query(Moralis.Role)   
    const roles = await roleQuery.find()    
    for (let i = 0; i < roles.length; i++) {
        if (roles[i].get('name') === "Admin") {
            logger.info(`Role Name: ${roles[i].get('name')}`) // getting role name
            logger.info(`Role's ObjectId: ${roles[i].id}`)  // getting role object
            const users = roles[i].getUsers();  // Trying to get the user object linked to `Admin` role but not able to get the user data.
            logger.info(`Keys: ${Object.keys(users)}`)
            logger.info(`Values: ${JSON.stringify(Object.values(users))}`)
}

try: const roles = await roleQuery.find({useMasterkey: true})

2 Likes