1

Делаю авторизацию и не могу получить токен из AsyncStorage код сохранения

_storeData = async (token, phone, password) => {
        try {
            await AsyncStorage.setItem('@token', token);
            await AsyncStorage.setItem('@phone', phone);
            await AsyncStorage.setItem('@password', password);
        } catch (error) {
            console.log(error);
        }
    };

считываю

    _retrieveData = async () => {
        try {
          const value = await AsyncStorage.getItem('token');
          if (value !== null) {
            console.log(value);
          }
        } catch (error) {
          // Error retrieving data
          console.log('error');
        }
      };

при считывании вообще ничего в консоль не выходит как получить данные из AsyncStorage? использую старый AsyncStorage чтобы с expo работал.

1 ответ 1

1

const value = await AsyncStorage.getItem('token');

вот здесь имя надо было прописать @token а не token

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.