Created
February 14, 2019 13:35
-
-
Save iiagodias/c5c00b921a8151f589f00fe1f2f25e8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async logar(email, senha, token, tipo){ | |
try { | |
if(email == ""){ | |
Alert.alert("Aviso", "Preencha o campo e-mail."); | |
}else if(senha == ""){ | |
Alert.alert("Aviso", "Preencha o campo senha."); | |
}else{ | |
this.setState({loading: true}); | |
const response = await fetch(`https://www.buscabelem.com.br/api/cadastro_login.php?login=${email}&senha=${senha}&token=${token}&tipo=${tipo}`); | |
const result = await response.json(); | |
if(result.status){ | |
this.setState({loading: false}); | |
await AsyncStorage.setItem("@BuscaBelem:usuario", JSON.stringify(result)); | |
this.props.navigation.dispatch(resetAction); | |
}else{ | |
this.setState({loading: false}); | |
Alert.alert("Aviso", "E-mail e senha incorreto."); | |
} | |
} | |
} catch (error) { | |
this.setState({loading: false}); | |
Alert.alert("Erro", "Erro na conexão."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment