DEPRECATION NOTICE: Getting timezone property of user object is deprecated. Use user_option object instead

I found a away around getting this deprecation notice, and still getting access to the user_field:

api.getCurrentUser().findDetails().then((user) => { ... });

However, findDetails will always send a request to the server. Nothing is cached. Once it is called, the current user will have a populated user_fields.

So you can optimize the logic a bit like:


function withUserFields(user, callback) {
  if (user.user_fields === undefined) {
    user.findDetails().then(callback);
  } else {
    callback(user);
  }
}

withUserFields(api.getCurrentUser(), (user) => {
  // do something with user.user_fields[]
});