BLOCKED_BY_ME — Users blocked by the logged-in user
HAS_BLOCKED_ME — Users who have blocked the logged-in user
BOTH — Both directions (default)
TypeScript
JavaScript
JavaScript
JavaScript
let limit: number = 30;let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() .setLimit(limit) .setDirection(CometChat.BlockedUsersRequest.directions.BLOCKED_BY_ME) .build();
let limit = 30; let blockedUsersRequest = new
CometChat.BlockedUsersRequestBuilder() .setLimit(limit).setDirection(CometChat.BlockedUsersRequest.directions.BLOCKED_BY_ME).build(); ```</Tab></Tabs>Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `BlockedUsersRequest` class.Once you have the object of the `BlockedUsersRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of [`User`](/sdk/reference/entities#user) objects containing n number of blocked users where N is the limit set in the builder class.<Tabs><Tab title="TypeScript">```typescriptlet limit = 30;let blockedUsersRequest = new CometChat.BlockedUsersRequestBuilder().setLimit(limit).setDirection(CometChat.BlockedUsersRequest.directions.BLOCKED_BY_ME).build();
let limit = 30; let blockedUsersRequest = new
CometChat.BlockedUsersRequestBuilder() .setLimit(limit).setDirection(CometChat.BlockedUsersRequest.directions.BLOCKED_BY_ME).build(); ```</Tab></Tabs>After configuring the builder, call `build()` to get the `BlockedUsersRequest` object, then call `fetchNext()` to retrieve blocked users.<Tabs><Tab title="TypeScript">```typescriptlet limit: number = 30;let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUsersRequestBuilder().setLimit(limit).build();blockedUsersRequest.fetchNext().then((userList: CometChat.User[]) => {console.log("Blocked user list received:", userList);}, (error: CometChat.CometChatException) => {console.log("Blocked user list fetching failed with error:", error);});
const limit = 30;const blockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() .setLimit(limit) .build();blockedUsersRequest.fetchNext().then(userList => { console.log("Blocked user list received:", userList);}, error => { console.log("Blocked user list fetching failed with error:", error);});
The fetchNext() method returns an array of User objects representing blocked users.Relevant fields to access on returned users: