# getAllUsers or queryUsers returns currently connected users instead of all users in the system

**URL:** <https://forum.social.plus/t/getallusers-or-queryusers-returns-currently-connected-users-instead-of-all-users-in-the-system/598>\
**Category:** Web\
**Created:** [December 10, 2022, 2:35pm UTC](https://forum.social.plus/t/getallusers-or-queryusers-returns-currently-connected-users-instead-of-all-users-in-the-system/598 "2022-12-10T14:35:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhiraj](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@Dhiraj](https://forum.social.plus/u/Dhiraj)\
**Post date:** [December 10, 2022, 2:35pm UTC](https://forum.social.plus/t/getallusers-or-queryusers-returns-currently-connected-users-instead-of-all-users-in-the-system/598/1 "2022-12-10T14:35:05Z")

</div>

getAllUsers or queryUsers returns currently connected users instead of all users in the system in **js sdk** whereas in typescript sdk it returns all the users. I wanted to list all the users available in the console but these functions aren’t working as per my usecase. Can you please let me know if there is a function for getting all users in js sdk?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [December 12, 2022, 7:40am UTC](https://forum.social.plus/t/getallusers-or-queryusers-returns-currently-connected-users-instead-of-all-users-in-the-system/598/2 "2022-12-12T07:40:12Z")

</div>

Hello, could you also please share with us your js code? and what’s your current version?

---

<div class="post-metadata">

**Author:** ![Dhiraj](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@Dhiraj](https://forum.social.plus/u/Dhiraj)\
**Post date:** [December 12, 2022, 9:10am UTC](https://forum.social.plus/t/getallusers-or-queryusers-returns-currently-connected-users-instead-of-all-users-in-the-system/598/3 "2022-12-12T09:10:18Z")

</div>

Hi, I am using the latest version using unpkg, which is 5.31.0 . Please find below my code:

```auto
const userRepo = new UserRepository();
const allUsers = userRepo.getAllUsers();
allUsers.on("dataUpdated", models =>{ models.map(model => {console.log(model.userId);})});

```

I also tried using the updated queryUsers function

```auto
 const liveUserCollection = UserRepository.queryUsers({
  filter: 'all',
 sortBy: 'displayName'
 }); 
 liveUserCollection.on("dataUpdated", models => { models.map(model => console.log(model.userId));}); 
});

```

Both of these functions are returning currently connected users instead of all users.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [December 12, 2022, 10:42am UTC](https://forum.social.plus/t/getallusers-or-queryusers-returns-currently-connected-users-instead-of-all-users-in-the-system/598/4 "2022-12-12T10:42:28Z")

</div>

Hello, could you pls try this code below? it should return 20 users per time

```auto
const userRepo = new UserRepository();
    const liveObject = userRepo.getAllUsers(UserSortingMethod.DisplayName);
    liveObject.on("dataUpdated", (user) => {
      console.log(user);
    });

```

---

<div class="post-metadata">

**Author:** ![Dhiraj](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@Dhiraj](https://forum.social.plus/u/Dhiraj)\
**Post date:** [December 12, 2022, 11:21am UTC](https://forum.social.plus/t/getallusers-or-queryusers-returns-currently-connected-users-instead-of-all-users-in-the-system/598/5 "2022-12-12T11:21:27Z")

</div>

Hello, I just tried this code. It is returning me just those users which connected to server today, not all users. Can you please check this on your end for js sdk just to make sure that this is not a bug?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [December 12, 2022, 11:44am UTC](https://forum.social.plus/t/getallusers-or-queryusers-returns-currently-connected-users-instead-of-all-users-in-the-system/598/6 "2022-12-12T11:44:46Z")

</div>

Hi, we already checked and it works fine for us. The users you received should be all users but you will have to loop it.

```auto
const userRepo = new UserRepository();
    const liveObject = userRepo.getAllUsers(UserSortingMethod.firstCreated);
    liveObject.on("dataUpdated", (user) => {
      console.log(user);
    });

```

It will be sorted by first created user

---

<div class="post-metadata">

**Author:** ![Dhiraj](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@Dhiraj](https://forum.social.plus/u/Dhiraj)\
**Post date:** [December 12, 2022, 12:07pm UTC](https://forum.social.plus/t/getallusers-or-queryusers-returns-currently-connected-users-instead-of-all-users-in-the-system/598/7 "2022-12-12T12:07:39Z")

</div>

Hello, Yeah I understand that I will have to loop through all the users that I receive as it is an array of objects but after running this code, it is not returning me all the users in the system. I verified it through length property of the result as well.  
Is it like on your end you tested with all the users which were connected to server through some or the other way, today itself? In that case it is returning all users as all of them were connected. It is not returning those users which don’t connect on the same day.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [December 13, 2022, 7:52am UTC](https://forum.social.plus/t/getallusers-or-queryusers-returns-currently-connected-users-instead-of-all-users-in-the-system/598/8 "2022-12-13T07:52:45Z")

</div>

Hello, we have received all users, please see the sample response below:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/amity/original/1X/ff24e1f92346214b0d296d81074d2a6a3f3b06ca.png)

If you would like us to check further on your network, please provide us your apikey and serverkey to our support email: [support.asc@amity.co](mailto:support.asc@amity.co)
