Skip to content

Commit

Permalink
Merge pull request #19 from evert/refresh-in-browser
Browse files Browse the repository at this point in the history
Clone before re-use of Request object. Fixes refresh in browsers.
  • Loading branch information
evert authored Mar 18, 2019
2 parents 37ee707 + 5fbbdf5 commit 0651771
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

0.3.3 (2019-03-18)
------------------

* When refreshing a token, browsers don't allow re-use of the same `Request`
object. Now we're cloning it before use.


0.3.2 (2019-03-13)
------------------

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fetch-mw-oauth2",
"version": "0.3.2",
"version": "0.3.3",
"description": "Fetch middleware to add OAuth2 support",
"main": "dist/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/fetch-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OAuth2 {

let accessToken = await this.getAccessToken();

let response = await requestWithBearerToken(request, accessToken);
let response = await requestWithBearerToken(request.clone(), accessToken);

if (!response.ok && response.status === 401) {

Expand All @@ -45,7 +45,7 @@ export default class OAuth2 {
response = await requestWithBearerToken(request, accessToken);

}
return fetch(request);
return response;

}

Expand Down

0 comments on commit 0651771

Please sign in to comment.