Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const login = async(values)=> {
- setLoader(true);
- try {
- const endpoint = 'http://localhost:3000/api/login';
- const data = values;
- const response = await axios.post(endpoint, data);
- if(response.status === 200){
- setResponseData(response.data);
- await AsyncStorage.setItem("id", JSON.stringify(responseData._id));
- await AsyncStorage.setItem("token", JSON.stringify(responseData.token));
- await AsyncStorage.setItem(`user${responseData._id}`, JSON.stringify(responseData));
- setLoader(false);
- navigation.replace('Bottom Navigation');
- }
- } catch (error) {
- console.log(error)
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement