Browse Source

API connection in LoginScreen

master
GabrielTrettel 3 years ago
parent
commit
84f1a1ea7b
  1. 5
      src/app/screens/LoginScreen.js

5
src/app/screens/LoginScreen.js

@ -78,14 +78,15 @@ export default function LoginScreen(props) {
const authContext = useContext(AuthContext); const authContext = useContext(AuthContext);
const handleSubmit = async (name, password, setLoginFailed) => { 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)); console.log(JSON.stringify(result));
if (!result.ok) return setLoginFailed(true); if (!result.ok) return setLoginFailed(true);
setLoginFailed(false); setLoginFailed(false);
const user = jwdDecode(result.data); const user = jwdDecode(result.data);
authContext.setUser(user); authContext.setUser(user);
console.log(user);
console.log("usuário: " + JSON.sstringify(user));
authStorage.setToken(result.data); authStorage.setToken(result.data);
}; };

Loading…
Cancel
Save