Search Posts

$resource:badcfg Error in resource configuration for action `query`. Expected response to contain an array but got an object

I am working on a few files which are based on angularjs, nodejs, html, etc.
I have got this error in the browser console.


“error: $resource:badcfg Response does not match configured parameter
Error in resource configuration for action query. Expected response
to contain an array but got an object (Request: GET


I am trying to get a set of information from a certain .json file. Here is the code(from an angularjs file) attached which calls the service(which is another nodejs file) to get the desired information. But on the browser page rendered by the corresponding html, I am getting the error which I mentioned before. I have attached both JS code snippets.

    $scope.refreshCompressionStats = function() {

    for (var i = 0; i < $scope.compressionProcesses.length; i++) {

        (function (i) {
            $scope.TotalImagesCompressed = 0;
            $scope.TotalImagesToCompress = 0;
            $scope.TotalImagesFailedToCompress = 0;
            var resAss = $resource("/pacs/getcompressionstats");
            var resp = resAss.query({process: $scope.compressionProcesses[i]});

            resp.$promise.then(function (response) {
                for (var k = 0; k < response.TaskQueuStatistics.WorkerStats.length; k++) {
                    $scope.TotalImagesCompressed += $scope.compressionProcesses[i].TaskQueuStatistics.WorkerStats[k].TotalTasksExecuted;

here is the node js code snippet… when I log this output, it is correctly shown in the terminal. but this is not reaching the calling function.. please help me out.

httpApp.get('/pacs/getcompressionstats', function(req, res, next) {
    try {
        fs.readFile(cfg.compressionstatspath + "compressionstats-" + req.query.process + ".json", function (err, data) {
            try {

                var msgs = JSON.parse(data);
                var msgs2 = [];
                msgs2 = JSON.stringify(msgs);
            catch (err) {
    catch (err) {

Source: AngularJS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.