Axios interceptor functions can be thought of like action filters or middleware in ASP.NET MVC. They are invoked on every single request that we make using axios, and we can hook into the request both before it has run and after. This makes them ideal for our refresh token requirements, as we can check every response that we get back from an API request and perform some custom logic if we detect an authentication failure.
In this case, we'll be looking for 401 response status codes, checking whether we have a refresh token to use, and then attempting to obtain a new access token using the new API endpoint we created earlier on. If we get one, we re-trigger the original request that failed, and the user is none the wiser that any of this has happened, unless they're watching the network tab in their browser devtools.
This...