# User JS Object \`groups\` array not populated for several users

**URL:** <https://meta.discourse.org/t/user-js-object-groups-array-not-populated-for-several-users/261520>\
**Category:** Development\
**Created:** [April 13, 2023, 2:02am UTC](https://meta.discourse.org/t/user-js-object-groups-array-not-populated-for-several-users/261520 "2023-04-13T02:02:24Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![smileBeda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/smilebeda/32/272497_2.png) [@smileBeda](https://meta.discourse.org/u/smileBeda)\
**Post date:** [April 13, 2023, 3:51am UTC](https://meta.discourse.org/t/user-js-object-groups-array-not-populated-for-several-users/261520/4 "2023-04-13T03:51:29Z")

</div>

@Lhc_fl, so what you did is get the current user’s username (I suppose with the same AJAX as I use?), then another AJAX to that user JSON, and from there the group?

I like as well @angus’ approach - my code though is on the discourse side… I could just use the same API key and authenticate with that?  
I had presumed, that since I use `withCredentials`… the code runs only when a user is authenticated, _and_ that the data would always be the same.

I am not sure why the data is not the same, is this a security concern to communicate _what group_ a user is in? It’s not that we communicate the actual group data, or other users in that group, as far I see.

In any case, venturing into the suggested approaches now…

Thanks!

---

_[View the full topic](https://meta.discourse.org/t/user-js-object-groups-array-not-populated-for-several-users/261520)._
