Search code examples
react-nativeasyncstorage

AsyncStorage not resolving or rejecting


I'm trying to get an item from async storage.

componentDidMount() {
    console.log('componentDidMount')
    AsyncStorage.getItem(STORAGE_KEY)
      .then(storage => console.log('then', storage))
      .catch(err => console.log('catch', err))
}

Also trying this way:

componentDidMount() {
    console.log('componentDidMount')
    AsyncStorage.getItem(STORAGE_KEY, (err, data) => {
      console.log('data', data);
      console.log('err', err)
    });
 }

But no matter how I do it, the debugger is outputting only the componentDidMount log and I'm not getting results at all.

Any idea what's wrong here?

EDIT: I'm running the app through expo


Solution

  • There was a problem with expo. After restarting expo completely the same code I originally posted worked fine.