Skip to content

Unable to get any item with getItem #604

Closed
@EricWiener

Description

@EricWiener

Current behavior

Unable to retrieve values with getItem

When using the following code:

import AsyncStorage from '@react-native-async-storage/async-storage';

  let storageKey = 'persist:root';
  console.log("Getting stored state", storageKey);
  (async () => {
    console.log('about to call async');
    try {
      let res = await AsyncStorage.getItem('persist:root');
      console.log("res", res);
    } catch(e) {
      // error reading value
      console.log(e);
    }
  })();

  console.log("passed here");
  AsyncStorage.getAllKeys((err, keys) => {
    AsyncStorage.multiGet(keys, (error, stores) => {
      stores.map((result, i, store) => {
        console.log({ [store[i][0]]: store[i][1] });
        return true;
      });
    });
  });

The top chunk never prints out an error or a result. I just get:

Getting stored state persist:root
about to call async
passed here

It just continues onto the bottom chunk where it correctly prints values:

{"persist:root": ...}

Expected behavior

The item should be returned when using await AsyncStorage.getItem('persist:root')

Repro steps

See above.

Environment

  • Platforms tested:
    • Android
    • iOS
    • macOS
    • Windows
  • AsyncStorage version: ^1.15.4
  • Environment:
System:
    OS: macOS 11.2.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 24.73 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.18.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.3.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 26, 28, 29
      Build Tools: 28.0.3, 29.0.2, 29.0.3
      System Images: android-28 | Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 12.5/12E262 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_242 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1
    react-native: 0.64.1 => 0.64.1
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
  • Logs/Errors that may be relevant:

Metadata

Metadata

Assignees

No one assigned

    Labels

    need infoNeed more information from the author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions