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')
        })
    }
  }
SAMER SAEID