In trying to understand a return result, I ended up with this simple thing:
fetch('http://localhost:8081/position', {mode: 'cors'})
.then(response => {return response.json()})
.then(result => console.log(result));
which works - it prints the json of the response.
But this does not work:
fetch('http://localhost:8081/position', {mode: 'cors'})
.then(response => {console.log(response.json()); return response.json();})
.then(result => console.log(result));
It thows Uncaught (in promise) TypeError: Failed to execute 'json' on 'Response': body stream is locked
Why is that?