Cannot invoke an object which is possibly 'undefined'

Hi everyone, can anyone help me with this? I trying to integrate Access Control with Supabase and when I'm trying invoke authProvider.getPermissions it throws an error.

here is my code for getPermissions

  getPermissions: async () => {
    const user = await supabaseClient.auth.getUser();

    if (user) {
      return user.data.user?.role;
    }

    const { data } = await supabaseClient.rpc('get_my_claim', {
      claim: 'role',
    });
    return Promise.resolve(data);
  },
Screenshot_2023-03-22_at_2.00.07_PM.png
Was this page helpful?