Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
El almacenamiento asíncrono no puede recuperar datos de reaccionar nativo

Estoy usando AsyncStorage para mantener los datos del usuario en el teléfono. Después de registrar al usuario, estoy tratando de recuperar al usuario si existe uno y automatizar la redirección a la página de perfil. pero tengo problemas con el almacenamiento asíncrono porque solo devuelve la palabra 'usuario' en la consola...

en el componente de inicio de sesión -> importar AsyncStorage desde '@react-native-async-storage/async-storage';

 const loggedUser = async () => { try { const u = await AsyncStorage.getItem('user'); console.log(u); } catch (error) { console.log(error); } };
 /** * * This function retrieve the data from the server and store it to the local database.. * */ const executeLogin = async (email, password) => { try { // Get data and store in async storage const response = await data.post('/api/login', {email, password}); storeData('user', response.data); -> //Check the code bellow for the source } // Catch all errors bellow catch (error) { if (error.response.status === 404 && error.response.data === 'Wrong credentials') { Alert.alert('Whoops!', 'You entered the wrong credentials. Please try again.'); } else { Alert.alert('Whoops!', 'Something went wrong. This is an unexpecred error. We will try to fix it as soon as possible'); } } }; export default executeLogin;

El bloque de código anterior llama a axios y supone almacenar los datos en un almacenamiento asíncrono. Pero tampoco tengo idea si funcionó porque no me dio ningún error...

 import AsyncStorage from '@react-native-async-storage/async-storage'; /** * * This function must only accept serialised object with JSON.stringfy() method * */ const storeData = async object => { try { await AsyncStorage.setItem('user', object); } catch (error) { console.log(error); } } export default storeData;

Esta es la función de tienda

No puedo entender lo que estoy haciendo mal.... Gracias, Daniel

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!