Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Examples of using $http.put in Angular?

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]);
like image 636
Jorge Bush Avatar asked Jun 18 '15 11:06

Jorge Bush


People also ask

How do I use HTTP PUT?

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.

What is the PUT method within HTTP?

The HTTP PUT request method creates a new resource or replaces a representation of the target resource with the request payload.

What is put method in Angular?

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.

What is the use of HTTP in Angular?

The AngularJS $http service makes a request to the server, and returns a response.


2 Answers

Second parameter must be an object:

$http.put('/api/v1/users/' + user.login, { login: "login", password: "password" }); 
like image 137
Roman Koliada Avatar answered Sep 23 '22 20:09

Roman Koliada


I use $http.put like this in my project.

$http.put(api/resources/:id, {name:name});
like image 30
EdisonGuo Avatar answered Sep 21 '22 20:09

EdisonGuo