Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
114
rated 0 times [  121] [ 7]  / answers: 1 / hits: 110054  / 11 Years ago, wed, february 26, 2014, 12:00:00

I have a resource 'roles' which has a many to many relationship with 'user'. To administer 'roles' I need to send the role id and the user id to the server so that it removes the the role from the correct user (not necessarily the logged in user)



Here is what I was attempting but according to the docs this is not possible. I know I can send the two ids in the uri but my laravel backend automatically sets up a resourceful route of resource/{resourceid} which I would like to use if possible. Is there a way to do this that I am missing?



var removeRole = function (roleid, userid) {
var input =[];
input.user = userid;

$http.delete('/roles/' + roleid, input).success(function (data, status) {
console.log(data);
});
};

More From » angularjs

 Answers
8

You can do an http DELETE via a URL like /users/1/roles/2. That would be the most RESTful way to do it.



Otherwise I guess you can just pass the user id as part of the query params? Something like



$http.delete('/roles/' + roleid, {params: {userId: userID}}).then...

[#72288] Tuesday, February 25, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
estefanib

Total Points: 508
Total Questions: 104
Total Answers: 83

Location: Lebanon
Member since Sun, Aug 2, 2020
4 Years ago
;