I am simply looking for best practice where I have a service helper that calls the fetch API and on error (status is not 200) I would like to alert the user with a message he / she can retry / cancel without the main React Native app crashing with a red screen.
I found this article on StackOverflow that seems to give the answer, but I wanted to hear if there is a better way to do this.
async doSomething() {
try {
let response = await fetch('someurl');
let result = await response.json();
// do something with result
} catch(e) {
alert('error');
}
}