Good day. I try to perform a POST request, but the data of the post parameter does not seem to go away, because sending a POST through a normal html form returns the correct answer. Where could I make a mistake?

app = angular.module('testApp', []); app.controller('TestCntr', ['$scope', '$http', function($scope, $http) { $scope.items = []; $http({ method: 'POST', url: 'http://portal.com/comp/api/', data: {md2: "74c32512c6c700672652fbcc7db70d18"} }) .then(function(response) { console.log(response.data); $scope.items = response.data; }); }]); 
  • Well, yes, he's just twitching in your controller. Do you need to send a request immediately when you open the page? - arrowd September
  • Immediately upon opening. - Valery Orlov
  • if ngRoute used ngRoute then the resolve method can be used, in this case, the filled objects item can be passed to the controller, by the way, and why you are not using the shortened version , i.e. $http.post(url, data).then() ? - Bald
  • Routing happens without ngRoute - Valery Orlov
  • one
    It may be called, but an error occurs on the server side. Since in your case error handling does not occur, you see nothing. Try after then write .catch(function(err){console.log(err)}) . - Stepan Kasyanenko

0