No params are send to PHP backend


I’m a bit confused, I can’t understand why there are no params sending to the backend:

var data = {"email":'mail', 'password': 'pass'}; 
promise = $http({
                url: 'http://my_url',
                method: "POST",
                data: data
            }).then(function(response) {
return promise;

Within the backend I’m just saying:


The request is working and I’m reaching the php without a problem, only my params are not there. I have no clue what I’m doing wrong?! I always get an empty array within console log:


Thanks for any help,


Try in your run block of your app (app.js in the default ionic app)

.run(['$http', function ($http) {
    $["Content-Type"] = "application/x-www-form-urlencoded";

and in your php

header('Content-Type: application/json');
$request = json_decode(file_get_contents("php://input"));
$somedata = $request->somedata;
echo json_encode($somedata);

Then use the post request that you posted.

1 Like

Hi Claw,

thanks for your fast response. This simple line did the job for me:

$request = json_decode(file_get_contents("php://input"));

But I’m still not sure why the $_POST[] is not working…

Thanks again, you saved me a lot of time!