Not able to access POST params in PHP when called from JS

I have created a very simple PHP file as displayed below.

If I call the API using postman, it works fine and prints the value of “a”.
But when I call through my javascript code, it only returns “……..>>>>>>>” but not the value of “a”.

header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: content-type,x-requested-with");
echo "........>>>>>>>";
$name = $_POST['a'];
echo $name;

Javascript code

fetch(url, {
method: "POST",
body: JSON.stringify(attrObj),
headers: {
"Content-type": "application/json",
},
})
.then((response) => response.json())
.then((json) => callback.call(obj, json));