mgonto / restangular

AngularJS service to handle Rest API Restful Resources properly and easily
MIT License
7.87k stars 840 forks source link

Response config is not present. #1460

Open olysyuk opened 7 years ago

olysyuk commented 7 years ago

I'm trying to make custom post on entity action (POST /environment/9/validated)

The code calling restangular is the following:

Restangular.one('website', $routeParams.websiteId).one('environment', environment.id)
                .customPOST({}, 'validate').then(function(data) {
                    console.log(data);
                });

Back-end returns 400 as a validation error that is shown in console

angular.js:12410 POST http://localhost:9001/api/v1/website/21/environment/9/validate 400 (Bad Request)

But then okCallback has no config for response:

TypeError: Cannot read property 'params' of undefined
    at okCallback (http://localhost:9001/app/bower_components/restangular/dist/restangular.js:1249:45)
    at processQueue (http://localhost:9001/app/bower_components/angular/angular.js:16648:37)
    at http://localhost:9001/app/bower_components/angular/angular.js:16692:27
    at Scope.$eval (http://localhost:9001/app/bower_components/angular/angular.js:17972:28)
    at Scope.$digest (http://localhost:9001/app/bower_components/angular/angular.js:17786:31)
    at Scope.$apply (http://localhost:9001/app/bower_components/angular/angular.js:18080:24)
    at done (http://localhost:9001/app/bower_components/angular/angular.js:12210:47)
    at completeRequest (http://localhost:9001/app/bower_components/angular/angular.js:12436:7)
    at XMLHttpRequest.requestLoaded (http://localhost:9001/app/bower_components/angular/angular.js:12364:9) Possibly unhandled rejection: {}

Line that assigns callback has number 1322 . Restangular version 1.6.1

olysyuk commented 7 years ago

It turns out that this happens if response is a malformed json. Feel free to close this issue if you think that lib behavior is correct.