Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Json response reactnative fetch login data

import {Alert} from 'react-native'

login = () => {
    if (this.state.username === '') {
      Alert.alert('Enter username !')
    } else if (this.state.password === '') {
      Alert.alert('Enter Password !')
    } else {
      api
        .createUser(this.state.username, this.state.password)
        .then((response) => {
            if(response.ok) {
              Alert.alert('Login successful')
            }else{
              Alert.alert('Check credentials')
            }
        })
        //If response is in json then in success
        
        //If response is not in json then in error
        .catch((error) => {
          //Error
          Alert.alert('Check credentials')
        })
    }
  }
 
PREVIOUS NEXT
Tagged: #Json #response #reactnative #fetch #login #data
ADD COMMENT
Topic
Name
8+8 =