getAvailableRoles

The getAvailableRoles method is used to retrieve a list of all available roles that can be granted within the market. This method fetches the roles from the backend and returns them as an array of role objects. Each role object contains details such as the role's ID, name, description, and value. This method is particularly useful for displaying all possible roles in a user interface or for selecting a role to assign to a user or group.

Parameters

None: This method does not require any parameters.

Returns

Promise<IRole[]>: A promise that resolves to an array of IRole objects. Each object represents a role and includes properties such as id, name, description, and value.

Usage Example

// Retrieve the list of all available roles
sdk.rolesService.getAvailableRoles()
  .then((roles) => {
    console.log('Available roles:', roles);
    // The roles array will contain objects with details about each role
    roles.forEach(role => {
      console.log(`Role ID: ${role.id}, Name: ${role.name}`);
    });
  })
  .catch((error) => {
    console.error('Error retrieving roles:', error);
  });