{"repo":"vlki/refresh-fetch","free":true,"listed":false,"github":"https://github.com/vlki/refresh-fetch","clone":"git clone https://github.com/vlki/refresh-fetch.git","description":"Wrapper around fetch capable of graceful authentication token refreshing.","language":"JavaScript","stars":86,"topics":["api","fetch","auth","token","refresh"],"license":"MIT","category":"auth-billing-email","readme_excerpt":"Refresh Fetch Wrapper around fetch capable of graceful authentication token refreshing. For situations when there is API which issues authentication tokens on login endpoint, API requires you to add the authentication token to all requests, those tokens must be refreshed every X minutes, and you just want to call fetch and be abstracted away from the refreshing. The following ES6 functions are required: Promise fetch Install Add to your app using package manager, eg.: Usage Example Motivation Imagine you have in your app a request to /api/data which needs authentication/authorization token in Authorization header like this: That is all fine and dandy, but what if you have to refresh the token, because it expires every 10 minutes? You will start doing something like this: And now you want to have the original request repeated. And also if there is request called during the refreshing, you don't want to start refreshing second time, but you just want to wait for the first refresh to complete and use the new token. Sigh. That's a lot you don't want to be writing in every app. With refresh-fetch you configure 3 parameters, shouldRefreshToken , refreshToken and fetch , and the refreshing works exactly like described. See it in action: License MIT","default_branch":null,"files":null,"tree":[],"storefront":"/r/vlki","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/vlki/refresh-fetch/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."}