Why `response.json()` must be awaited

Bosco Domingo - Nov 5 - - Dev Community

Credit to the source, I'm just putting it in writing for easier access!

It turns out json() must be awaited because fetch() will resolve or reject when it receives the response headers, regardless of what the body is! The body is likely to be much larger in size, and may even take a long time to arrive and/or might do so in chunks, thus it has to be awaited even after fetch() has finished.

I had no idea why this behaviour existed until now. I love learning deeper stuff like this, and hope you do too!

Again, watch the video for a better and more visual explanation! (it's 6 minutes long, worth every second)

. . . . . . . . . . . .
Terabox Video Player