Created
February 14, 2019 13:16
-
-
Save iiagodias/022efbabb6c3fe2c8335d55bbbf7e755 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
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