Skip to content

Instantly share code, notes, and snippets.

@iiagodias
Created February 14, 2019 13:16
Show Gist options
  • Save iiagodias/022efbabb6c3fe2c8335d55bbbf7e755 to your computer and use it in GitHub Desktop.
Save iiagodias/022efbabb6c3fe2c8335d55bbbf7e755 to your computer and use it in GitHub Desktop.
logar(email, senha, token, tipo){
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});
fetch(`https://www.buscabelem.com.br/api/cadastro_login.php?login=${email}&senha=${senha}&token=${token}&tipo=${tipo}`).then((response)=>{
response.json().then((result)=>{
if(result.status){
this.setState({loading: false});
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