Answer the question
In order to leave comments, you need to log in
How to make a put request with api in angular?
How to make a put request with api in angular?
You need to make a PUT request to the API backend and pass the parameters:
{
"params" : ["apple", "potato"]
}
Tried following the example, but it doesn't work) I started to understand Angular quite recently
var myApp = angular.module("myApp", []);
myApp.controller("HttpPutController", function ($scope, $http) {
$scope.UpdateData = function () {
var data = $.param({
зфкфьі: ["apple", "potato"] ,
});
$http.put('http://*****/getmenu?'+ data)
.success(function (data, status, headers) {
$scope.ServerResponse = data;
})
.error(function (data, status, header, config) {
$scope.ServerResponse = htmlDecode("Data: " + data +
"\n\n\n\nstatus: " + status +
"\n\n\n\nheaders: " + header +
"\n\n\n\nconfig: " + config);
});
};
});
Answer the question
In order to leave comments, you need to log in
var data = $.param({
зфкфьі: ["apple", "potato"] ,
});
$http.put('/some/url', {
someKey: ["apple", "potato"] ,
}).then(function (response) {
// не пользуйтесь .success/.error
}, function (reason) {
// пользуйтесь только промисами.
});
$http.get('/something', {
params: {
query: 'param'
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question