UserSettings

current-user. UserSettings

new UserSettings()

Source:

Handles communication with the userSettings endpoint. Can be used to get or save userSettings.

Methods

all() → {Promise}

Source:

Loads all the user settings of current user and returns them as an object from the promise.

d2.currentUser.userSettings.all()
 .then(userSettings => {
   console.log('UI Locale: ' + userSettings.keyUiLocale);
 });
Returns:

Promise that resolves with the usersettings object from the api.

Type
Promise

get(key) → {Promise}

Source:
d2.currentUser.userSettings.get('keyUiLocale')
 .then(userSettingValue => {
   console.log('UI Locale: ' + userSettingValue);
 });
Parameters:
Name Type Description
key String

The identifier of the user setting that should be retrieved.

Returns:

A promise that resolves with the value or will fail if the value is not available.

Type
Promise

set(key, value) → {Promise}

Source:
d2.currentUser.userSettings.set('keyUiLocale', 'fr')
 .then(() => {
  console.log('UI Locale is now "fr");
 });
Parameters:
Name Type Description
key String

The identifier of the user setting that should be saved.

value String

The new value of the user setting.

Returns:

A promise that will resolve when the new value has been saved, or fail if saving fails.

Type
Promise