title: AngularJS - Expected response to contain an object but instead got an array
body: <p>I'm trying to create an object in Angular.</p>
  
  <p>Here is my factory</p>
  
  <pre><code>angular.module('myApp')
      .factory('Order', function($resource) {
          return $resource('/api/products?id=:id/orders?id=:orderId', { id: "@_id" }, {
              query: { method: 'GET', isArray: false },
              update: { method: 'PUT'}
          });
      });
  </code></pre>
  
  <p>Here is my controller</p>
  
  <pre><code>angular.module('myApp').controller('OrderCtrl',
    function ($scope, $rootScope, $stateParams, Order, Auth) {
      $scope.myOrder = Order.get({"id": 1, "orderId": 1});
    }
  });
  </code></pre>
  
  <p>Here is my routes.js file in my server directory</p>
  
  <pre><code>app.use('/api/products', require('./api/product'));
  </code></pre>
  
  <p>In my api/products directory, I have an index file</p>
  
  <pre><code>var express = require('express');
  var controller = require('./product.controller');
  
  var router = express.Router();
  // Endpoints for products
  router.get('/', controller.index);
  router.get('/:id', controller.show);
  router.post('/', controller.create);
  router.put('/:id', controller.update);
  router.patch('/:id', controller.update);
  router.delete('/:id', controller.destroy);
  
  // Endpoints for product - order definitions
  router.get('/:id/orderDefinitions', controller.showOrderDefinitions);
  router.post('/:id/orderDefinitions', controller.addOrderDefinitions);
  
  // Endpoints for product - orders
  router.get('/:id/orders', controller.showProductOrders);
  router.get('/:id/orders/:orderId', controller.showIndividualProductOrder);
  router.put('/:id/orders/:orderId', controller.updateIndividualProductOrder);
  router.delete('/:id/orders/:orderId', controller.deleteOrder);
  
  module.exports = router;
  </code></pre>
  
  <p>Here are the two endpoints I'm trying to access</p>
  
  <pre><code>router.get('/:id/orders/:orderId', controller.showIndividualProductOrder);
  router.put('/:id/orders/:orderId', controller.updateIndividualProductOrder);
  </code></pre>
  
  <p>Here is my controller</p>
  
  <pre><code>exports.showIndividualProductOrder = function(req, res) {
    Product.findById(req.params.id, function (err, product) {
      if(err) { return handleError(res, err); }
      if(!product) { return res.send(404); }
      Order.find({productId: product._id, _id: req.params.orderId}, function (err, order) {
        console.log("found individual product order", order);
        if(err) { return handleError(res, err); }
        if(!order) { return res.send(404); }
        // Get product's order
        return res.json(order[0]);
      });
  
    });
  };
  
  // Update an individual order for a product
  exports.updateIndividualProductOrder = function(req, res) {
    Order.find({productId: product._id, _id: req.params.orderId}, function (err, order) {
      if(err) { return handleError(res, err); }
      if(!order) { return res.send(404); }
  
      var updatedOrder = _.merge(order, req.body);
      console.log("updating order", order, updatedOrder);
      updatedOrder.save(function (err) {
        if (err) { return handleError(res, err); }
        return res.json(200, product);
      });
  
    });
  };
  </code></pre>
  
  <p>And yet, I still get this error</p>
  
  <blockquote>
    <p>Error: [$resource:badcfg] Error in resource configuration for action <code>get</code>. Expected response to contain an object but got an array (Request: GET /api/products?id=1/orders?id=1)</p>
  </blockquote>
  
  <p>I used <code>Postman</code> to test the API endpoints, and the JSON output is an array. But in my factory, I clearly stated that I didn't want an array with the <code>isArray</code> option.</p>