Possible Unhandled Promise Rejection Type Error Undefined is not an object

0

I have this code in my React Native project:

static async validateSub(sub,pin) {

   sub_can_access = 'no'

   url = 'https://server.com/validator.php'

   let resp = await fetch(url + '?param1='+sub+'&param2='+pin);

   if (resp._bodyText.indexOf("TRUE") >= 0) {

       AsyncStorage.setItem('email', sub)
       AsyncStorage.setItem('password', pin)
       sub_can_access = 'yes'

    } else {

       alert('Try Again');

    }
}

The server returns the text TRUE Blah Blah Blah. And on Android it works fine, but for iOS, the variable resp comes undefined.

What could be happening?

    
asked by Jhonmer Araujo 03.04.2018 в 20:11
source

1 answer

1

In your XCode project you must enable Allow Arbitrary Loads in the info.plist

    
answered by 27.04.2018 / 11:25
source