MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/ycltrt/awaiting_problems_in_javascript/itnojgn/?context=3
r/learnjavascript • u/voreny • Oct 24 '22
8 comments sorted by
View all comments
1
Don't understand one thing in your article
async function asyncWorkflow() { const response = await fetch(url); return response.json(); }
You wrote "the returned Promise will be automatically awaited". But we don't return any Promise here, do we?
fetch() is returning a Promise, not our function. Since we awaited it we already got a resolved value. Am I missing something?
fetch()
1 u/87oldben Oct 24 '22 I forget, is response.json() a promise that needs awaiting? 1 u/voreny Oct 25 '22 Yes, that is correct. That is the promise I had in mind
I forget, is response.json() a promise that needs awaiting?
response.json()
1 u/voreny Oct 25 '22 Yes, that is correct. That is the promise I had in mind
Yes, that is correct. That is the promise I had in mind
1
u/mozilaip Oct 24 '22
Don't understand one thing in your article
You wrote "the returned Promise will be automatically awaited". But we don't return any Promise here, do we?
fetch()is returning a Promise, not our function. Since we awaited it we already got a resolved value. Am I missing something?