angularjs - Avoid a property from body of Angular Resource POST request -


i creating angular resource follows.

var book = $resource(baseurl + 'v1/users/:username/books/:id', {         username: '@username'         id: '@bookid'       }); 

i sending post call using save() follows. book.save({username:'testuser', bookid:1, show: true})

this generates url properly

v1/users/testuser/books/1 

but sends username,id in body along show:true want avoid. how avoid username,id in body?

here how, acheived it. used transformrequest property of actions , deleted unnecessary properties.

var book = $resource(baseurl + 'v1/users/:username/books/:id', {         username: '@username'         id: '@bookid'       }, {       customsave: {          method: 'post',          transformrequest: function(body) {             delete body.username;             delete body.id;             return angular.tojson(body);          }       } }); 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -