fetch('/api.php', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
action: 'auth',
payload: {
email: ...,
password: ...
}
})
});
<?php
require_once 'auth.class.php';
if ($_POST['action'] === 'auth') {
Auth::isAuth($_POST['payload']);
}