Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancel a request when cached data is available #926

Closed
ghelton opened this issue Oct 29, 2014 · 5 comments
Closed

Cancel a request when cached data is available #926

ghelton opened this issue Oct 29, 2014 · 5 comments

Comments

@ghelton
Copy link

ghelton commented Oct 29, 2014

I would like to send a request and have Restangular intercept and resolve the request if cached data is available. This may be related to #589 but I came up with a jsfiddle which demos how I'm attempting to do this:
http://jsfiddle.net/astrism/q9qyox50/13/

The request is still made when the code runs. Any ideas?

@f0def
Copy link

f0def commented Feb 13, 2015

Change

                var defer = $q.defer();
                defer.reject();
                httpConfig.timeout = defer;

to

                var defer = $q.defer();
                defer.resolve();
                httpConfig.timeout = defer.promise;

Example here http://jsfiddle.net/q9qyox50/14/

@fmclopes
Copy link

The request is cancelled but the cached data is not sent.

Any suggestions?

@f0def
Copy link

f0def commented Feb 15, 2015

I wrote example, using decorator for $http, that caching request promise to prevent multiple request to the same url
Example here (http://jsfiddle.net/referee/hh30bh0q/)

@grabbou
Copy link
Contributor

grabbou commented Feb 22, 2015

To review & update docs.

@daviesgeek
Copy link
Collaborator

Will update docs with referenced issue #1391

bostrom added a commit that referenced this issue Dec 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants