Ask Your Question
2

Is it necessary to employ async in a function that only gives back the output of Promise.resolve()?

asked 2023-06-16 14:09:42 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-06-16 14:34:02 +0000

nofretete gravatar image

No, it is not necessary to employ async in a function that only gives back the output of Promise.resolve(). You can simply use Promise.resolve() to return a resolved promise with the specified value. However, if the function involves some asynchronous operations, using async/await is recommended to ensure the code is executed in the expected order.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-16 14:09:42 +0000

Seen: 9 times

Last updated: Jun 16 '23