Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default class Login extends Component {
- constructor(props) {
- super(props);
- this.state = {
- email : '',
- password : '',
- loading : false,
- };
- this.LoginUser = this.LoginUser.bind(this);
- }
- //for login\\\
- LoginUser = () =>{
- this.setState({
- loading: true
- });
- if (this.state.email == "") {
- ToastAndroid.show('nama Tidak Boleh Kosong', ToastAndroid.SHORT)
- } else if (this.state.password == "") {
- ToastAndroid.show('Password Tidak Boleh Kosong', ToastAndroid.SHORT)
- } else {
- this.setState({
- loading: false
- })
- axios({
- method: 'POST',
- url: 'http://192.168.214.2/Auth/user',
- // headers:{
- // Authorization : 'Bearer' + token
- // },
- data: {
- email : this.state.email,
- password : this.state.password
- },
- })
- .then(response => {
- if (response == 'Try Again') {
- ToastAndroid.show('Try Again, the input is empty', ToastAndroid.SHORT)
- } else {
- ToastAndroid.show('sukses', ToastAndroid.SHORT)
- this.props.navigation.dispatch(resetAction)
- // this.props.navigation.dispatch(goHome)
- // console.log(navigateAction)
- }
- })
- .catch((error) => {
- console.log(error)
- this.onLoginFail();
- });
- Keyboard.dismiss()
- }
- }
- onLoginFail() {
- this.setState({
- loading: false
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement