{"repo":"Flyrell/axios-auth-refresh","free":true,"listed":false,"github":"https://github.com/Flyrell/axios-auth-refresh","clone":"git clone https://github.com/Flyrell/axios-auth-refresh.git","description":"Library that helps you implement automatic refresh of authorization via axios interceptors. You can easily intercept the original request when it fails, refresh the authorization and continue with the original request, without user even noticing.","language":"TypeScript","stars":1144,"topics":["axios","axios-plugin","interceptor","stalled-requests","token","authentication","middleware","http-interceptor","typescript"],"license":"MIT","category":"auth-billing-email","readme_excerpt":"axios-auth-refresh Library that helps you implement automatic refresh of authorization via axios interceptors. You can easily intercept the original request when it fails, refresh the authorization and continue with the original request, without any user interaction. What happens when the request fails due to authorization is all up to you. You can either run a refresh call for a new authorization token or run a custom logic. The plugin stalls additional requests that have come in while waiting for a new authorization token and resolves them when a new token is available. Installation Using npm or yarn: Syntax Parameters - axios - an instance of Axios - refreshAuthLogic - a Function used for refreshing authorization ( must return a promise ). Accepts exactly one parameter, which is the failedRequest returned by the original call. - options - object with settings for interceptor (See available options) Returns Interceptor id in case you want to reject it manually. Usage In order to activate the interceptors, you need to import a function from axios-auth-refresh and call it with the axios instance you want the interceptors for, as well as the refresh authorization function where you need to write the logic for refreshing the authorization. The interceptors will then be bound onto the axios instance, and the specified logic will be run whenever a 401 (Unauthorized) status code is returned from a server (or any other status code you provide in options). All the new requests creat","default_branch":null,"files":null,"tree":[],"storefront":"/r/Flyrell","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/Flyrell/axios-auth-refresh/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}