send data http angularjs error [duplicated]

-1

someone could guide me I'm sending data from a service to an api I'm doing it with slim and angularjs but somehow the api does not take the values I sent and probe the api with postman and it works then I imagine it is in the way in which I send the values with the angular someone who will guide me in that I am failing.

so I receive the values on the side of the api:

$json = $app->request->post('json'); $data = json_decode($json, true); $sql='SELECT * FROM compra_de_municion where id_empresa='.$empresa.' and fecha_Compra between "'.$data['fecha1'].'" and "'.$data['fecha2'].'" and calibre='.$data['calibre']; die($sql);

this is the way I sent the data to the api:

post: function(value){
        let json=angular.toJson(value);
        console.log(json);
        return $http({
            method:'POST',
            url:link+'total1',
            data:json,
            headers: {
                'Content-Type': 'application/json'
            } 
    
asked by Codigo Tutorial 22.09.2017 в 19:57
source

1 answer

0

the way I solved it was this by changing the post with the getBody

$json = $app->request->getBody(); $data = json_decode($json, true); $sql='SELECT * FROM compra_de_municion where id_empresa='.$empresa.' and fecha_Compra between "'.$data['fecha1'].'" and "'.$data['fecha2'].'" and calibre='.$data['calibre']; die($sql);

    
answered by 22.09.2017 в 21:32