I was going through the docs of the Request interface in Fetch API https://developer.mozilla.org/en-US/docs/Web/API/Request
The example where we set the body does not seem to work. Tried on chrome dev console (version 84.0.4147.89) and also on firefox (84.0).
const request = new Request('https://example.com', {method: 'POST', body: '{"foo": "bar"}'});
console.log(request.url);
console.log(request.method);
console.log(request.body);
This results in,
https://example.com/
POST
undefined
What am I doing wrong here...?
EDIT:
The following is working,
request.json().then((j)=>{console.log(j)});
This leads me to believe that the body was set, but the getter is not working for some reason.
Can anyone shed light on what's going on?