Catch fetch error in service helper and alerting users in main React Native app


(Bastien Mazeran) #1

Hello,

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 gives an answer and appears to be working, but I wanted to hear from the community if this is the recommended way.

Thank you,