I have a React Native Frontend & Express.js backend. My backend calls a 3rd party API, to use this API you must provide an OAuth key for that user which expires every 2 hours. Sometimes when I call the API it returns with a 400 error saying OAuth is expired and if it has then generate a new OAuth key and save on Frontend. How can I add a check to all my Axios requests to see if the OAuth key has expired. Is this better to handle on the Frontend or Backend?
I think you could use a try-chatch statement to check if the key throws any errors.