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);
});
});