Q:

Ionic2 & Angular2 $http POST request

I'm currently trying to post some data to an external PHP file. 
Issue:
Recieving Log Error: SyntaxError: Unexpected token < in JSON at position 0
Data Parameters not posting as headers.
What I'm trying to accomplish
Push username to API and get a JSON response with data to push to HTML table.
My code
.controller('listController', ['$scope','$http', function($scope,    
$http){

  console.log("HTTP request initialized.");

      var request = $http({
        method: "post",
        url:"http://test.com/user/projects.php",
        data: {
            username: "jimmie",
        },
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    });

    console.log(request);

    /* Response:  */
    request.success(function (data) {
        console.log(data); // outputs **Recieving Log Error:** Above 
    });
}])

Question
I'm using this method in app.js so the HTML can use ng-controller requests to call the method on start of the app. Since I've researched this issue for a while, and found lots of discrete issues in Angular 2 mostly, but the code is completely different, and not using the $http requests, as well not using .controller with $scope's. 
Can I approach this issue in an simpler way? Since the application will mostly only be built with GET and POST requests.
GET Request
I tried a GET request on my own API, just to check wether it's an outdated module I'm using, but the GET worked, but method: post with data won't.
Thanks, Jimmie.
 =)

A:

Your post method accept an object rather than string
var obj = {
     username: "test"
 }
var request = $http({
        method: "post",
        url:"http://test.com/user/projects.php",
        data: obj,
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    });

