'How To Prevent Request 500 Error in React.js?

I'm building a project. Client side is React.js and Server side is MCV(Web Api). Sometimes some of my functions' requests(axios) return 500 error. But This is a momentary error. Because When I call this service again in a while then it works well. Is there any way to prevent it? Is it a solution if I call this function using try-catch when it goes catch then call it again? Can you give me some advice what way should I go?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source