<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/the-problem-with-returning-values-from-async-await-functions-r-qtt0ki" -->

---
title: The Problem with Returning Values from Async Await Functions
description: Async and await are syntactic sugars for promise nesting. Where await will block the main thread until the promise is resolved. Can you guess the output of...
canonical: https://daily.dev/posts/the-problem-with-returning-values-from-async-await-functions-r-qtt0ki
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: The Problem with Returning Values from Async Await Functions | daily.dev
og:description: Async and await are syntactic sugars for promise nesting. Where await will block the main thread until the promise is resolved. Can you guess the output of...
og:url: https://daily.dev/posts/the-problem-with-returning-values-from-async-await-functions-r-qtt0ki
og:image: https://api.daily.dev/og/posts/r_qTt0KI_.png
og:image:alt: The Problem with Returning Values from Async Await Functions
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The Problem with Returning Values from Async Await Functions

**[JavaScript in Plain English](https://daily.dev/sources/jsPlainEnglish)** · 2 min read · 57 upvotes · 6 comments

## Summary

Async and await are syntactic sugars for promise nesting. Where await will block the main thread until the promise is resolved. Can you guess the output of below snippet? You’re wrong, the output is 1. Because an async function always returns a promise and rather resolving the promise in above example we are trying to extract the value out of it.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://javascript.plainenglish.io/problem-with-returning-values-from-async-await-function-javascript-e99c94a47ca5>

## Community discussion

Top comments from developers on daily.dev.

**@russelldsanders** · 3 upvotes

> Not sure this is exactly a problem with anything... This is just how Promises are intended to work. The title smells slightly of clickbait making it sound like there's an issue without a solution

**@ignusg** · 2 upvotes

> For newcomers, before you do anything with async await you have to learn how promises work, how they resolve and how to access their values.
>
> Async await is just syntactic sugar around them. You’ll do more harm than good if you use this syntax without understanding how it works.
>
> I see posts like these every couple of months explaining async await never even mentioning promises, talking about confusing syntax and weird behaviour.

**@grayson** · 1 upvotes

> The return value returns {Promise} without using await on return

**@mrgrigri** · 1 upvotes

> The best solution would be to use top-level await. But until it's widely supported, your solution, or a IIFY would work.

**@lakshya\_munjal** · 0 upvotes

> I got into a similar problem during my internship days. It's a must read for beginners.
> Easy to understand, yet we can get it wrong sometimes.

---

Tags: [#javascript](https://daily.dev/tags/javascript)

[View this post on daily.dev](https://daily.dev/posts/the-problem-with-returning-values-from-async-await-functions-r-qtt0ki)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"The Problem with Returning Values from Async Await Functions","url":"https://daily.dev/posts/the-problem-with-returning-values-from-async-await-functions-r-qtt0ki","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/the-problem-with-returning-values-from-async-await-functions-r-qtt0ki"},"datePublished":"2021-08-09T13:21:18.649Z","dateModified":"2021-10-07T14:17:10.317Z","description":"Async and await are syntactic sugars for promise nesting. Where await will block the main thread until the promise is resolved. Can you guess the output of...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9aa3b24e113696e9b109ad8e8b0c0565","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9aa3b24e113696e9b109ad8e8b0c0565","isAccessibleForFree":true,"articleSection":"JavaScript in Plain English","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"JavaScript in Plain English","logo":"https://media.daily.dev/image/upload/s--Dg5QTRuI--/f_auto,q_auto/v1686665538/logos/pe","url":"https://daily.dev/sources/jsPlainEnglish"},"commentCount":6,"discussionUrl":"https://daily.dev/posts/the-problem-with-returning-values-from-async-await-functions-r-qtt0ki","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":57},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":6}],"keywords":"javascript","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"JavaScript in Plain English","item":"https://daily.dev/sources/jsPlainEnglish"},{"@type":"ListItem","position":3,"name":"The Problem with Returning Values from Async Await Functions"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/the-problem-with-returning-values-from-async-await-functions-r-qtt0ki","comment":[{"@type":"Comment","text":"Not sure this is exactly a problem with anything… This is just how Promises are intended to work. The title smells slightly of clickbait making it sound like there’s an issue without a solution","datePublished":"2021-08-10T01:11:53.037Z","url":"https://daily.dev/posts/r_qTt0KI_#c-qqif-zrPR","author":{"@type":"Person","name":"Russell Sanders","url":"https://daily.dev/russelldsanders","image":"https://avatars.githubusercontent.com/u/32251280?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3}},{"@type":"Comment","text":"For newcomers, before you do anything with async await you have to learn how promises work, how they resolve and how to access their values.\nAsync await is just syntactic sugar around them. You’ll do more harm than good if you use this syntax without understanding how it works.\nI see posts like these every couple of months explaining async await never even mentioning promises, talking about confusing syntax and weird behaviour.","datePublished":"2021-10-17T09:19:11.350Z","url":"https://daily.dev/posts/r_qTt0KI_#c-rAaH4gCDv","author":{"@type":"Person","name":"IgnusG","url":"https://daily.dev/ignusg","image":"https://media.daily.dev/image/upload/f_auto/v1643464938/avatars/PlPdeFARQ"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"The return value returns {Promise} without using await on return","datePublished":"2021-08-09T19:27:42.637Z","dateModified":"2021-08-09T19:28:03.770Z","url":"https://daily.dev/posts/r_qTt0KI_#c-MP1R1KxD_","author":{"@type":"Person","name":"Grayson McMurry","url":"https://daily.dev/grayson","image":"https://lh3.googleusercontent.com/a-/AOh14Gg3tP0frAbLO0IElt3nDanjMn7wDIRpZhY6XiOP=s100"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"The best solution would be to use top-level await. But until it’s widely supported, your solution, or a IIFY would work.","datePublished":"2021-08-09T16:08:26.968Z","url":"https://daily.dev/posts/r_qTt0KI_#c-PpYsLQGRG","author":{"@type":"Person","name":"Michael Richins","url":"https://daily.dev/mrgrigri","image":"https://avatars2.githubusercontent.com/u/4528551?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"I got into a similar problem during my internship days. It’s a must read for beginners.\nEasy to understand, yet we can get it wrong sometimes.","datePublished":"2021-08-09T17:50:22.747Z","url":"https://daily.dev/posts/r_qTt0KI_#c-I01YeE1vM","author":{"@type":"Person","name":"Lakshya Munjal","url":"https://daily.dev/lakshya_munjal","image":"https://lh3.googleusercontent.com/a/AATXAJw6EYWd6EcHFieZsUfAXeZhFd3YaLHaamkZgpjL=s100"}}]}
```

