Detect a fetch request in PHP
PHP Snippet 1:
fetch(url, {
headers: {
'credentials': 'same-origin',
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/json'
// or 'Content-Type': 'application/x-www-form-urlencoded'
},
method: 'POST'
})