Skip to content

Cancel a request when cached data is available #926

Closed

Description

@ghelton

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?

Activity

  1. f0def commented on Feb 13, 2015

    @f0def

    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/

  2. fmclopes commented on Feb 14, 2015

    @fmclopes

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

    Any suggestions?

  3. f0def commented on Feb 15, 2015

    @f0def

    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/)

  4. grabbou commented on Feb 22, 2015

    @grabbou
    Contributor

    To review & update docs.

  5. daviesgeek commented on Jun 17, 2016

    @daviesgeek
    Collaborator

    Will update docs with referenced issue #1391

  6. added a commit that references this issue on Dec 30, 2016
    8552c51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions