0

Ok, I've tried looking at this How can I post data as form data instead of a request payload?

However, I still can't seem to send my request properly. Here are the details.

$scope.myData = {a: 123, b: 456};
$http({
        url: 'myfile',
        method: "POST",
        data: JSON.stringify($scope.myData),
        headers: {'Content-Type': 'application/json'}
})

This keeps being sent as request payload. Any ideas?

When I use 'application/x-www-form-urlencoded' The formdata is used however it is not parsed properly and the whole json is just one string when I look in the Chrome console.

Community
  • 1
  • 1
KingKongFrog
  • 13,946
  • 21
  • 75
  • 124

1 Answers1

0

$http provides an option : params.

Use params: instead of data:

 $http({
        url: 'myfile',
        method: "POST",
        params: JSON.stringify($scope.myData),
        headers: {'Content-Type': 'application/json'}
})
Nicolas2bert
  • 1,142
  • 7
  • 10