Hi,
I am currently follwing the Graceful asynchronous programming with Promises chapter.
I have reached the step about multiple promises and there is a little point that I do not understand.
Here is the step in question : https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Promises#running_code_in_response_to_multiple_promises_fulfilling
My question is about the following code :
I do not understand what is the role of the return keyword (in line 2) before the fetch call. What would it change if the return keyword was not there? It is explained later but I still don’t get it :
Second, we have added the
return
keyword before thefetch()
call. The effect this has is to run the entire chain and then run the final result (i.e. the promise returned byblob()
ortext()
) as the return value of the function we’ve just defined. In effect, thereturn
statements pass the results back up the chain to the top.
Thanks for your help,
Have a nice day
Ben