How to Check Role in client script

In the Below Code i get the Object But i cant access the role of that user

   frappe.call({
        method:'frappe.client.get',
        args:{
            doctype:'User',
            name:frm.doc.assigned_to,
            
        },
        callback:function(response){
            
            var data = response.message; 
            console.log( data)

            
            
            
        }
    })
}

In Python.

roles = frappe.get_roles(frappe.session.user)
print(roles)
if "Rom_DM_Role" in roles:
   category_name = 'Dining'
if "Rom_Chef_Role" in roles:
   category_name = 'Kitchen'

in Javascript

let role_avail = frappe.user_roles.includes("System Manager")

or

if (frappe.user.has_role("Role Name")) {
    console.log("The current user has the specified role.");
} else {
    console.log("The current user does not have the specified role.");
}

I hope this might be helpful to you.
Reference

1 Like