undefined is not an object (evaluating '_asyncStorage.AsyncStorage.getItem')

Please provide the following:

  1. SDK Version: 42
  2. Platforms(Android/iOS/web/all): Android
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

I use
@react-native-async-storage/async-storage”: “~1.15.0”

import { AsyncStorage } from “@react-native-async-storage/async-storage”

const getData = async () => {
try {
const value = await AsyncStorage.getItem(’@storage_Key’)
if (value !== null) {
console.log(value);
}
} catch (e) {
console.log(e);
}

}

ERROR
undefined is not an object (evaluating ‘_asyncStorage.AsyncStorage.getItem’)

Maybe you don’t have a value for that key?

I have resolved it.

I show the code.
@react-native-async-storage/async-storage”: “~1.15.0”
import AsyncStorage from “@react-native-async-storage/async-storage”

for set muli:

for get muli:

useEffect(() => {
        AsyncStorage.multiGet([STORAGE_KEY_TOKEN, STORAGE_KEY_PROFILE])
            .then(data => {
                console.log(data[0][1]);
                console.log(JSON.parse(data[1][1]));
            })
            .catch((error) =>
                console.log(error)
            )
    }, []);
AsyncStorage.multiSet([
            [STORAGE_KEY_TOKEN, whenTokenBeat],
            [STORAGE_KEY_PROFILE, JSON.stringify(whenProfileBeat)]
        ])
            .then(data => {
                console.log("save multiSet ok");
            })
            .catch((error) =>
                console.log(error)
            )

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.