From 84f1a1ea7b94e194af1ab90da051cf53c0df5fe4 Mon Sep 17 00:00:00 2001 From: GabrielTrettel Date: Wed, 20 Oct 2021 12:38:18 -0300 Subject: [PATCH] API connection in LoginScreen --- src/app/screens/LoginScreen.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/screens/LoginScreen.js b/src/app/screens/LoginScreen.js index 4a6e8aa..f3e58b8 100644 --- a/src/app/screens/LoginScreen.js +++ b/src/app/screens/LoginScreen.js @@ -17,7 +17,7 @@ import authStorage from "../auth/storage"; import assets from "../config/assets"; import Button from "../components/Button"; import { TouchableNativeFeedback } from "react-native-gesture-handler"; -//import authApi from '../api/auth'; +// import authApi from '../api/auth'; import login from "../api/auth"; const phoneRegex = RegExp( @@ -78,14 +78,15 @@ export default function LoginScreen(props) { const authContext = useContext(AuthContext); const handleSubmit = async (name, password, setLoginFailed) => { - const result = login(name, password);//await authApi.login(name, password); + const result = await login(name, password); console.log(JSON.stringify(result)); + if (!result.ok) return setLoginFailed(true); setLoginFailed(false); const user = jwdDecode(result.data); authContext.setUser(user); - console.log(user); + console.log("usuário: " + JSON.sstringify(user)); authStorage.setToken(result.data); };