03-02-2018 02:08 - edited 03-02-2018 02:08
03-02-2018 02:08 - edited 03-02-2018 02:08
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).
03-02-2018 10:52
03-02-2018 10:52
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.
08-26-2018 03:03
08-26-2018 03:03
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?
06-02-2019 09:55
06-02-2019 09:55
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.
06-02-2019 09:58
06-02-2019 09:58
Welcome to Fitbit development 😉 moreover, things like this will probably never get fixed due to "backwards compatibilty".