I have the following js snippet:
fetch('/some/webhook', {
method: 'post',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({test:'1'})
}).then(function(res) {
// do something here
}).then(function(data) {
// do something else here
});
For hours I am trying to get the body to my server, but the listening script sees nothing in the $_POST variable. The webhook receives the request. A simple:
die (var_dump($_POST));
results in an empty array shown in the console where I would have expected to see the variable test
with value 1.
What is wrong?