You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
As per AngularJS documentation, each request (cached or not) should return the response with the "config – {Object} – The configuration object that was used to generate the request.". ( https://docs.angularjs.org/api/ng/service/$http ).
AngularJS is basically totally ignoring current request config and returns the cached one (cache miss one).
The fix for this is to replace the line above with:
cachedResp.then(function (response) {
response.config = config;
return response;
}, function (response) {
response.config = config;
return response;
}).then(removePendingReq, removePendingReq);
MORE INFO ON THE REAL USE CASE
Our app required an ajax service that would handle different cases:
when network timeout occurs, stack the requests and trigger them when network is on
when a session token expired, stack the requests, wait for the session token and trigger the requests again
In the above context, we were forced to add our own "currentRequests" array and we use a "requestId" number to identify the request when it comes back. The problem is that with this cache we are triggering requests 7 and 8 for instance and we get back 7 twice.
NOTE: I can create a branch and make a pull request with the above fix, if desired.