I have a frontend in angular which consume API in php/slim3.
I call a php api with this post request :
return this.http.post<any>(API_URL + '/user', { data: userData });
With these form values : {name: "john", age: "25"}
in the api I have this code :
$app->post('/user', function (\Slim\Http\Request $request, \Slim\Http\Response $response) {
$input = $request->getParams();
$name = $input['name'];
$age = $input["age"];
echo json_encode($name);
}
When i run my app it returns null instead of name, but when i use postman with the same values it returns the good value.
I have tried with :
$input = $request->getParsedBody();
it's the same result.
What am i doing wrong ?
Thank you and sorry for my bad english...