I'm trying to get JSON information from POST request. My POST request is:
var money = document.getElementById("code").value;
const Http = new XMLHttpRequest();
const url='/paypal/';
Http.open("POST", url);
Http.setRequestHeader("Content-Type", "application/json");
Http.send(JSON.stringify({
value: money
}));
And the controller is:
public function paypal(Request $r) {
$postInput = file_get_contents('php://input');
$data = json_decode($postInput, true);
$response = array('value' => $data);
return Response::json($response);
}
but the only result that I get is:
{"value":null}
Any idea where is my problem?