Issue reading HTTP request body from a JSON POST in PHP Issue reading HTTP request body from a JSON POST in PHP json json

Issue reading HTTP request body from a JSON POST in PHP


Thanks to others for the input. It turns out that I just needed

$inputJSON = file_get_contents('php://input');$input = json_decode($inputJSON, TRUE); //convert JSON into array

where the second parameter in json_decode returned the object as an array.

Hope this helps someone else!


Even when the following works.

$inputJSON = file_get_contents('php://input');

If you want to continue using $_POST send the data as FormData

var fd = new FormData();fd.append('key', 'value');return axios.post('url', fd)