Hi im making a form that send a search request to my slim API
the form works, data gets posted but in slim i get the data as a string:
form post angular $scope.submitForm = function() { console.log("--> Submitting form");
$http({
url: "http://localhost/c2dapi/search",
data: $scope.searchForm,
method: 'POST',
headers : {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'}
}).success(function(data){
console.log("OK", data)
}).error(function(err){"ERR", console.log(err)})
};
//SLIM API
$app->post('/search', function () use ($app){
$request = $app->request();
$body = $request->getBody();
var_dump($body);
});
now this is my first angular + rest aproach so maybe im wrong but when i var dump the body in slim i get OK string(18) "{"zipCode":"3434"}"
I know there are ways to break up this string in php to get the value, but is this the right way or can i get the data also as a php array in slim ?