Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restangular Delete with body data

Below is my restangular delete request where i intend to pass an array of ids to delete based on user selection

var deleteIds = [1,5,10]
Restangular.all('url').customDELETE(deleteIds);

I want this deleteIds to be passed in body params. How can i send the array as body so tat i could see the request payload.

like image 879
Alaksandar Jesus Gene Avatar asked Apr 19 '16 13:04

Alaksandar Jesus Gene


1 Answers

Actually I also needed to use the delete http method with data passed in the body, and I found that Restangular supports a customOperation

documentation: https://github.com/mgonto/restangular#custom-methods

  • customOperation(operation, path, [params, headers, elem]): This does a custom operation to the path that we specify. This method is actually used from all the others in this subsection. Operation can be one of: get, post, put, remove, head, options, patch, trace

example:

Restangular.all('some/path/123')
    .customOperation('remove', '',{'content-type': 'application/json'},[1,5,10])
like image 70
Marcelo Waisman Avatar answered Nov 02 '22 03:11

Marcelo Waisman