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

Asynchronous task in response interceptor? #1153

Open
jpetitcolas opened this issue May 26, 2015 · 3 comments
Open

Asynchronous task in response interceptor? #1153

jpetitcolas opened this issue May 26, 2015 · 3 comments

Comments

@jpetitcolas
Copy link

I am currently trying to implement ng-admin with a Loopback API. As Loopback provides collection length in a separate route (/api/cars/count), I would like to decorate the response with a totalCount property retrieved from this URL.

Here is what I've done so far:

app.run(['Restangular', '$http', function(RestangularProvider, $http) {
    RestangularProvider.addResponseInterceptor(function(data, operation, what, url, response, deferred) {
        if (operation !== 'getList') {
            deferred.resolve(data);
        }

        $http.get(url + '/count')
            .success(function(countData) {
                response.totalCount = countData.count;
                deferred.resolve(data);
            })
            .error(function(error) {
                deferred.reject(error);
            });
    });
}]);

Does Restangular interceptor deals correctly with asynchronous tasks?

Probably related to #893.

@jpetitcolas
Copy link
Author

Bump! :)

@fracz
Copy link

fracz commented Sep 4, 2015

+1

Seems that response interceptor can not return promise currently. When I do for the getList method, I get the Response for getList SHOULD be an array and not an object or something else error message.

@akomm
Copy link

akomm commented Nov 9, 2015

+1

Need this to handle compaction of jsonld, when context is an URI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants