# 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:** 5

<div class="post-metadata">

**Author:** ![Lhc\_fl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lhc_fl/32/268115_2.png) [@Lhc\_fl](https://meta.discourse.org/u/Lhc_fl)\
**Post date:** [April 13, 2023, 4:18am UTC](https://meta.discourse.org/t/user-js-object-groups-array-not-populated-for-several-users/261520/5 "2023-04-13T04:18:53Z")

</div>

If you are developing components for discourse… I think the easiest way is to use discourse’s api. If you are developing a client, I think the user name should have been known long ago?

For the former, here is an example;

```plaintext
require("discourse/lib/plugin-api").withPluginApi("1.0.0", (api)=>{console.log(api.currentUser())});

```

---

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