0
$scope.logout = function () {
    //var auth_token = $cookieStore.get('auth_token');
    Auth.delete({
      'auth_token': $cookieStore.get('auth_token')
    }, function(data){
      $scope.isLoggedIn = false;
      $cookieStore.remove('auth_token');
    });

When this called it given me an error:

Error: [$resource:badcfg] http://errors.angularjs.org/1.2.27/$resource/badcfg?p0=object&p1=array
z/<@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js:6:450
t/</f[d]/q<@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular-resource.min.js:8:1
De/e/l.promise.then/J@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js:101:87
De/e/l.promise.then/J@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js:101:87
De/f/<.then/<@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js:102:259
Yd/this.$get</h.prototype.$eval@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js:113:28
Yd/this.$get</h.prototype.$digest@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js:110:109
Yd/this.$get</h.prototype.$apply@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js:113:360
m@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js:72:452
w@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js:77:463
ye/</B.onreadystatechange@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js:79:24

http://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js
Line 92
2
  • errors.angularjs.org/1.2.27/$resource/…. If you go to the URL given in your error it explains the problem. Your $resource is configured to return an array but the server is sending an object, or vice versa. Change your resource configuration, there is an isArray property that you can set to true or false accordingly. Commented Dec 25, 2014 at 8:50
  • use non-minified version of angular to know the error details Commented Dec 25, 2014 at 8:57

1 Answer 1

1

Its a common problem. The delete method of resource model is expecting a json response which must be an object but your server is returning the json data in array format. So you have two options either change your server code to respond the json object data or change your resource model something like:

var Auth = $resource('/your-server-url', {}, {
    delete: {
       isArray: false
    }
});

Hope this helps!

Thanks,
SA

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.