I notice that when doing fetch e.g. fetch('/')
, I get an object back but one where the content is locked and I have to do e.g. await fetch('/').then(response=>response.text())
I thought maybe it’s locked because of something to do with promises, but I notice that I can do
async abc() {return 123;}
await abc()
(doing abc()
returns a promise 'cos it’s an async function, but when doing await abc()
it returns the number 123… so I don’t think await fetch would be returning a promise so I don’t think promise is the issue).
so as I say, await abc()
returns 123. So why is it that ‘fetch’ returns an object with a locked field ? and it looks like the content is only accessible with ‘then’ i.e. not with await fetch('/')).text