How to query roles with React?

I’m checking out Moralis for the first time today. Saw a few of the tutorials and read the documentation. Currently, I’m trying to query the Roles (_Role) but all I get is an empty array.

Code:

—> Table permissions, table, & console logs (Link to Imgur)

P.S. not sure if it matters but I’m using NextJs

Hi can you try using useMoralisQuery like this just to see if you can get any data.

Otherwise this issue may be related to this one. React-moralis find user given an objectId - Moralis - Moralis Forum

Hi! thanks for your help

My goal is to be able to check if the current user has a “Staff” Role. My idea was to

  1. directly query the _Roble table
  2. get the role and use role.getUsers() <- -check if the current user is included in there

Not sure if this is the correct way of checking the current user role. Here are the screenshots, I tried just checking the data but it’s still empty.

Btw, other tables work just fine. I’m only having issues with “_Role”

Table:

Permissions:

Code:

Log:

it may be easier to make a cloud function that returns the information that you need and then to call that cloud function from react

1 Like