http request with AngularJS to a PHP server that responds with status -1

0

I am sending an http request from Angular to a PHP server and he replies this:

{
  "data": null,
  "status": -1,
  "config": {
    "method": "POST",
    "transformRequest": [
      null
    ],
    "transformResponse": [
      null
    ],
    "data": {},
    "url": "http://api.elpozon.com/rest/login",
    "headers": {
      "Accept": "application/json",
      "Content-Type": "application/json;charset=utf-8"
    }
  },
  "statusText": ""
}

When I do it from POSTMAN, it returns the login information.

This is the function in Angular that executes the request.

$scope.intentoDeLoginPozon = function(){

        var datapost = {
                method: 'POST',
                data: {
                    user : $scope.username,
                    pass: $scope.password
                },
                url: 'http://api.elpozon.com/rest/login',
                headers:{
                    'Accept': 'application/json'
                }
            };

            $http(datapost).then(function successCallback(response){
                $scope.mensaje = response;


            }, function errorCallback(response){
                $scope.error = response;

            }); 
    }

I do not have any information on how the PHP Server is programmed.

What explanation exists for this?

    
asked by Roger Araque 07.04.2017 в 03:47
source

1 answer

0

Yes, they are the same parameters. I spoke with the administrator of the php server and he tells me that I forgot to place the headers, especially this one: 'Content-Type: application/json; charset="UTF-8" Now when I make the request, the server returns the user's info.

    
answered by 09.04.2017 / 18:24
source