My app is crashing hard when doing certain API calls, and I narrowed it down to this point:
- it's not an HTTP vs HTTPS thing
- I eventually used two different mock APIs, and to my suprise, one worked, the other didn't. Both are basically the same, see snippet below
- same behavior on both WIFI or cellular network
- same issue in axios instead of fetch
- the
catchblock is invoked with a nondescript network error, but then the app still crashes hard
Environment: Android 10 (actual device), RN 0.61.5
Both calls below just do a simple HTTP GET which results in a JSON snippet being returned. One works, the other causes a hard crash.
async foo() {
try {
// this endpoint CRASHES my app
const r = await fetch("http://jsonplaceholder.typicode.com/todos/1");
// this endpoint works just fine
//const r = await fetch("http://echo.jsontest.com/key/value/one/two");
} catch(e) {
console.log("Invoked, but the app still crashes hard right after");
}
}