Are there any simple examples of using the $http.put
method in Angular? Specifically, I'm unsure about what the data/Request content
parameter should be, should it be an object or an object property?
$http.put(url, data, [config]);
PUT HTTP RequestThe PUT method requests that the enclosed entity be stored under the supplied URI. If the URI refers to an already existing resource, it is modified and if the URI does not point to an existing resource, then the server can create the resource with that URI.
The HTTP PUT request method creates a new resource or replaces a representation of the target resource with the request payload.
The PUT method is used for updating an object which is already saved in the database. It also requires two parameters, first the URL and second request body. For updating the object, we need to pass the object ID in the URL as a route parameter. Delete the Post.
The AngularJS $http service makes a request to the server, and returns a response.
Second parameter must be an object:
$http.put('/api/v1/users/' + user.login, { login: "login", password: "password" });
I use $http.put like this in my project.
$http.put(api/resources/:id, {name:name});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With