Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in resource configuration. Expected response to contain an object but got an array

I have an angular response that expects an array and the service call passes an array(can see it in network tab of chrome dev tools).

but I'm getting the following error in chrome console.

Error in resource configuration. Expected response to contain an object but got an array

here is my angular service:-

physicalServerModule.factory("physicalServerServices", ['$resource',
function ($resource) {

    var host = app.general.host;
    var port = app.general.port;

    var serverItemPath = 'v1/physicalserver/:x';
    var serverPath = 'v1/physicalserver/list';


    return {
        physicalServer: function () {
            return $resource(host + serverPath,{}, {
                query: {
                    method: 'GET',
                    isArray: true
                },
                create: {
                    method: 'POST'
                }
            });
        }
};
}]);

and I'm calling my service as below:-

var tileServiceCall = physicalServerServices.physicalServer();
tileServiceCall.get({},{}).$promise.then(function (response) {


 app.meta.physicalserver.tileItems = JSON.stringify(response);

}, function (error) {
alert("error");

});

my angularjs version is 1.2.15 can someone point me the root cause?

like image 414
helloworld Avatar asked Jun 25 '14 12:06

helloworld


1 Answers

Change tileServiceCall.get(..) to tileServiceCall.query(...).

like image 170
Ronald91 Avatar answered Oct 13 '22 06:10

Ronald91