Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

169
Vistas
Expo Securestore. Can't save userid and token after auth

I am trying to save userId and token in securestore. On the next screen I can get token from securestore, but I can't see userid

  const doUserLogIn = async() => {
    try {
      const response = await fetch('http://someurl-dev.de/api/login/?email='+email+'&password='+password, {
        method: 'POST',
        headers: {
          Accept: 'application/json',
          'Content-Type': 'application/json'
        }
      });
      const json = await response.json();
      SecureStore.setItemAsync('userid', json.userId);
      SecureStore.setItemAsync('token', json.token);
    } catch (e) {
      alert('Error1:'+e);
    } finally {
      try{
        navigation.navigate('Schichten');
      } catch(e) {alert('Error2:'+e); }
    }
  }

And here's the json returned by api call

{"userId":9,"token":"957a230f3eb6e63c47f1d7a0805fe31df6d2ced7","vorname":"Ankit","nachname":"Vij"}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You are not awaiting the async functions setItemAsync. You should try the following:

await SecureStore.setItemAsync('userid', json.userId);
await SecureStore.setItemAsync('token', json.token);

Additionally, you can try to log the value of the json variable to make sure that it does contain the userId and token properties.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda