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