Skip to content

Commit

Permalink
Add safety call on request
Browse files Browse the repository at this point in the history
  • Loading branch information
neorel committed Jun 1, 2021
1 parent fb6ba87 commit d3f546f
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/attach.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@ function interceptor(fetch, ...args) {
promise = promise.then(args => request(...args), requestError);
}
});

let request = null;


// Register fetch call
promise = promise.then(args => {
request = new Request(...args);
return fetch(request);
}).then(response => {
response.request = request;
return response;
}).catch(error => {
error.request = request;
return Promise.reject(error);
const request = new Request(...args);
return fetch(request).then(response => {
response.request = request;
return response;
}).catch(error => {
error.request = request;
return Promise.reject(error);
});
});

// Register response interceptors
Expand Down

0 comments on commit d3f546f

Please sign in to comment.