Reputation: 7348
In my React Native app, I'm trying to make an API call with this code:
test = async () => {
try {
let a = await fetch('https://rxapitest.alliancepharmacygroup.ca:12345/', {
method: 'GET',
}).then(response => {
console.log("success")
})
} catch(err) {
console.log("error")
}
}
On Android this works fine. In Postman the request works fine. And when I replace the URL with https://google.com
or something, it works fine. So it seems that the problem is with this particular URL for iOS only.
Here's my stacktrace:
Does anyone know how I can approach this?
Upvotes: 1
Views: 1235
Reputation: 587
Did you try to add the NSAppTransportSecurity policy in info.plist? Like that:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
Upvotes: 2