DEV Community

Discussion on: How to Manage Multiple Threads in Node JS

Collapse
 
srikanth597 profile image
srikanth597

hmm,
but in my opinion, i think if any function that surrounded by ASYNC statement would always return the promise, no matter if it's really asynchronous or not.

Thread Thread
 
febryanph profile image
febryanph

I think you miss some statement, not offending your opinion but if you write await on the body function that wrapped with async statement, the return will synchronus. You can check on this link javascript.info/async-await#await, with example showAvatar function.

First Picture

Second Picture

I give an example, on the first picture, the variable githubUser using await statement to retrieve the value from fetch, it will return the actual value that send by the server.

On the second picture, the return was Promise that we knew it asynchronous. The value can be fulfilled or rejected and need chained function to process the result.

Thread Thread
 
srikanth597 profile image
srikanth597

I understand your point, it's definitely returning resolved value or rejected value.