# getUsers doesn't include recently updated metadata

**URL:** <https://community.auth0.com/t/getusers-doesnt-include-recently-updated-metadata/6242>\
**Category:** Get Help\
**Tags:** metadata\
**Created:** [April 18, 2017, 4:16am UTC](https://community.auth0.com/t/getusers-doesnt-include-recently-updated-metadata/6242 "2017-04-18T04:16:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![justinwarner](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@justinwarner](https://community.auth0.com/u/justinwarner)\
**Post date:** [April 18, 2017, 4:16am UTC](https://community.auth0.com/t/getusers-doesnt-include-recently-updated-metadata/6242/1 "2017-04-18T04:16:26Z")

</div>

I am using the node-auth0 package, and I have a call to management.updateUserMetadata() followed by management.getUsers(). The response from getUsers() doesn’t seem to include the changes that I made to the metadata in updateUserMetadata(). If I call getUser for the specific updated user then I can see the updates, but getUsers() doesn’t seem to include the results, unless if I wait for a few seconds before calling it. Are these methods not synchronized? Or is there something I am doing wrong? I’ve included some sample code below that illustrates the issue I am seeing with a simple nested callback.

```
var auth0 = require('auth0');
var _ = require('lodash');

let ManagementClient = auth0.ManagementClient;
let management = new ManagementClient({
    token: 'token',
    domain: 'domain'
});

var userId = 'auth0|userid';
var metadata = {
    testValue: 'newValue'
};

management.updateUserMetadata({ id: userId }, metadata).then(function(updateResponse) {
    // This response looks correct:
    console.log(updateResponse);

    let params = {
        per_page: 100,
        page: 0,
        q: 'identities.connection:connection-name'
    };
    management.getUsers(params).then(function(auth0Users) {
        var findUser = _.find(auth0Users, { user_id: userId });
        // this still has the data that looks like prior to the update above. 
        console.log(findUser); 
    });
});

```

---

<div class="post-metadata">

**Author:** ![Abhishek\_Hingnikar1](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@Abhishek\_Hingnikar1](https://community.auth0.com/u/Abhishek_Hingnikar1)\
**Post date:** [April 18, 2017, 11:08am UTC](https://community.auth0.com/t/getusers-doesnt-include-recently-updated-metadata/6242/2 "2017-04-18T11:08:08Z")

</div>

This is caused because `getUsers` implements ElasticSearch and the data needs to be indexed in ElasticSearch before you can retrieve it. Unfortunately, this can take upto a few seconds, if you know the `user_id` ahead of time. Its better to use `getUser` instead as it’ll return the true state of the user.

---

<div class="post-metadata">

**Author:** ![justinwarner](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@justinwarner](https://community.auth0.com/u/justinwarner)\
**Post date:** [April 18, 2017, 11:30pm UTC](https://community.auth0.com/t/getusers-doesnt-include-recently-updated-metadata/6242/3 "2017-04-18T23:30:39Z")

</div>

Got it, thank you for the reply. That makes sense, and explains the behavior I am seeing. Unfortunately it doesn’t make things easier, as I am building an internal screen that show a list of users, and a screen for editing a user. When you “save” your changes to a user I navigate back to the screen that lists users, and I query using getUsers(), but it doesn’t show my latest saved changes. I can work-around this, but it’s not as clean as I would have hoped.

Thank you again for the explanation!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:53am UTC](https://community.auth0.com/t/getusers-doesnt-include-recently-updated-metadata/6242/4 "2018-03-02T05:53:18Z")

</div>


