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

257
Visualizações
(SOLVED) React Native - Expo SecureStore API apparently not working

Here's my code (followed this guide: https://docs.expo.dev/versions/latest/sdk/securestore/):

fetch('<APIurl>', {
    method: 'POST',
    body: formBody,
    headers: {
    //Header Definition
    'Content-Type':
    'application/x-www-form-urlencoded;charset=UTF-8',
    },
})
.then((response) => response.json())
.then((responseJson) => {
    console.log(responseJson.id_user);
    // If server response message same as Data Matched
    if (responseJson.status != '0 results') {
    //Alert.alert("Excellent!", "Please go on");
    
    async function save(key, value) {
        await SecureStore.setItemAsync(key, value);
    }
    async function getValueFor(key) {
        let result = await SecureStore.getItemAsync(key);
        if (result) {
        alert("🔐 Here's your value 🔐 \n" + result);
        } else {
        alert('No values stored under that key.');
        }
    }

    save(id_user, responseJson.id_user);
    getValueFor(id_user);

    //navigation.navigate('InsertCodeScreen');
    } else {
    console.log('Please check your mobileNumber');
    }
})
.catch((error) => {
    //Hide Loader
    console.error(error);
});

it returns Can't find variable: id_user

Strangely, if I do save(responseJson.id_user, responseJson.id_user); it works perfectly, but if in an another screen I do getValueFor(responseJson.id_user);, the app complains that cannot find responseJson variable.

But by the way, isn't the first argument of save() the name I want to give to the item I want to store?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Solved: haven't realized before that the "key" for save() must be a string

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