Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

170
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda