Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SettingsStorage.getItem from settings component

settings/index.jsx

      <TextInput
        title="API key"
        settingsKey="apiKey"
      />

companion/settings.js

import { settingsStorage } from 'settings';

console.log(settingsStorage.getItem('apiKey'));

 

Writing some 'api key value' in the TextInput component, then the log outputs:

{"name":"api key value"}

Isn't this strange? I mean, I expected it to be right the value, and not a stringified object with a 'name' property whose content is a 'value' (not even a name).

Best Answer
0 Votes
4 REPLIES 4

Thanks for the feedback, we're aware of some issues and inconsistencies with the getItem method. It's actually different for each type of component, and we'll aim to resolve this in a future update.

Best Answer

Half a year later this is still the same and not documented at all... will this be fixed in the future or do you just won't fix/ignore it for backwards compatibility?

Best Answer

so wait, is:

 

JSON.parse(settingsStorage.getItem("some_key")).name

the way to actually get at the value? It actually seems to work, i'm just kinda blown away that this isn't at least addressed a tiny bit in the docs.

Best Answer
0 Votes

Welcome to Fitbit development 😉 moreover, things like this will probably never get fixed due to "backwards compatibilty".

Best Answer
0 Votes