I'm am using the Slim Framework Version 3 and have some problems.
$app-> post('/', function($request, $response){
$parsedBody = $request->getParsedBody()['email'];
var_dump($parsedBody);
});
result is always:
null
Can you help me ?
I'm am using the Slim Framework Version 3 and have some problems.
$app-> post('/', function($request, $response){
$parsedBody = $request->getParsedBody()['email'];
var_dump($parsedBody);
});
result is always:
null
Can you help me ?
Please, try this way:
I hope this helps you!
It depends how you are sending data to the route. This is a POST route, so it will expect the body data to standard form format (
application/x-www-form-urlencoded
) by default.If you are sending JSON to this route, then you need to set the
Content-type
header toapplication/json
. i.e. the curl would look like:Also, you should validate that the array key you are looking for is there: