I have an order resource that looks like this.
.factory('Order', order) order.$inject = ['$resource', "ApiEndpoint"]; function order($resource, ApiEndpoint) { return $resource(ApiEndpoint.url + 'orders.json', {}, { create: {method: 'POST', url: ApiEndpoint.url + 'orders.json'}, update: {method: 'PUT'}, edit: {method: 'GET', url: ApiEndpoint.url + 'orders/edit.json'}, remove_item: {method: 'GET', url: ApiEndpoint.url + 'orders/remove_item.json'}, }); }
When I run Order.update like this
var params = { order: { line_items_attributes: {0: {quantity: 2, id: 1}} }, order_id: 3 }; Order.update(params, function (resp, respHeaders) { console.log("response headers", respHeaders()); console.log("change quantity resp", resp); })
I also tried this:
Order.update({}, params, function (resp, respHeaders) { console.log("response headers", respHeaders()); console.log("change quantity resp", resp); })
Parameters sent to the server go to the URL. For example, this was one of the URLs received by the server.
path="/api/mobile/orders.json?order=%7B%22line_items_attributes%22:%7B%220%22:%7B%22quantity%22:8,%22id%22:356265%7D%7D%7D"
It should also be noted that the method accepted by the server is an OPTIONS request. For this, a server has been configured.
Since I am sending a PUT request, why is $resource passing parameters via a URL and not part of the payload?