I am little bit frustrated with my below angular code, as it is not sending the JSON data to my spring boot based micro-service running in the same machine. Please help me out! FYI, I am a newbie to JavaScript world.
$scope.addBook = function() {
var data = $.param({
json: JSON.stringify({
name: $scope.bookName,
isbn: $scope.isbn,
author: $scope.authorName,
pages: $scope.pages
})
});
var config = {
headers : {
'Content-Type': 'application/json'
}
}
var result = $http.post('http://localhost:8080/book', data, config);
result.success(function (data, status, headers, config) {
$scope.result = JSON.stringify({data: data});
});
result.error(function (data, status, header, config) {
$scope.result = JSON.stringify({data: data});
});
};