I want to learn how fetch works. Backend is very simple
<?php
print_r(json_encode($_POST['test']));
And I created this fetch
fetch('http://localhost/test.php', {
method: 'POST',
body: JSON.stringify({
test: 'test'
})
})
.then(res => res.json())
.then(data => console.log(data))
All the time this code return null in console.log. Where I make a mistake?