I fetch data to server, and I want to see in the console params, which i send. But on PHP side $_POST value is empty and I always recieve empty array.(WEB -> PHP -> WEB) What I do wrong ?
JS code:
function json(response){
return response.json()
}
let data = {obj : 'value'};
fetch('http://localhost/Fetch_mysql_angular/requests.php', {
method: 'post',
headers: {
'Accept': 'application/json',
"Content-type": "application/json"
},
body: JSON.stringify(data)
})
.then(json)
.then(function (data) {
console.log(data);
})
.catch(function (error) {
console.log('Request failed', error);
});
PHP code:
<?php
echo json_encode($_POST);
?>
Console
[]
Thanks for spending time on my post!