Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular $resource PUT method, can't make it work

Tags:

angularjs

I use a REST api and I'd like to update on of my project objects with a PUT request. The request is supported in the API, and I'm trying to use $resource to PUT the data, but it doesn't seem to work. Here is what I do :

var projectResource = $resource('/api/projects/' + projectId, {update: {method: "PUT"}});
    $scope.editProject = function(editedProject) {
        projectResource.$update(editedProject);
    }

Where editedProject is the project with the new values, filled by a form in a webpage. I know there is something wrong in my projectResource declaration, but I don't find what. Help !

like image 231
Nepho Avatar asked Dec 08 '22 14:12

Nepho


1 Answers

Try this:

$resource('/api/projects', { id: projectId }, {
    update: { method: 'PUT' }
});
like image 127
species Avatar answered Dec 29 '22 13:12

species