Advertisement
Andre1966

Login error solution

Sep 24th, 2023
988
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.69 KB | Software | 0 0
  1. const login = async(values)=> {
  2.     setLoader(true);
  3.     try {
  4.       const endpoint = 'http://localhost:3000/api/login';
  5.       const data = values;
  6.  
  7.       const response = await axios.post(endpoint, data);
  8.  
  9.       if(response.status === 200){
  10.        
  11.         setResponseData(response.data);
  12.  
  13.         await AsyncStorage.setItem("id", JSON.stringify(responseData._id));
  14.         await AsyncStorage.setItem("token", JSON.stringify(responseData.token));
  15.         await AsyncStorage.setItem(`user${responseData._id}`, JSON.stringify(responseData));
  16.         setLoader(false);
  17.  
  18.         navigation.replace('Bottom Navigation');
  19.       }
  20.     } catch (error) {
  21.       console.log(error)
  22.     }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement