question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Async/await not working?

See original GitHub issue

I try this:

    let [one, two] = await connection.execute('SELECT EXISTS(SELECT 1 FROM bashbase.users WHERE email=?) AS "exists";', [req.body.email])

    console.log(one, two)

(node:19626) UnhandledPromiseRejectionWarning: TypeError: (intermediate value) is not iterable

when I try to add a .then, it says connection.execute.then is not a function

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
JiaJiaJiangcommented, May 24, 2018

what about returning a Promise if no callback is provided?

1reaction
sidorarescommented, Jan 9, 2020

@AdrianHastro I guess @SinghRajKr question was “is this example in top level scope? If yes, it won’t work because node does not have top level await yet” - see https://stackoverflow.com/questions/46515764/how-can-i-use-async-await-at-the-top-level

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript async/await not working - Stack Overflow
I am using the async/await keywords, but not having any luck. Any help appreciated. This is my attempt to try getting it to...
Read more >
javascript - await does not wait for Promise to finish
@SachinHooda await operator can only be used inside an async function, failing this would throw a runtime error as "Can not use keyword...
Read more >
Async/await - The Modern JavaScript Tutorial
In actuality, The `await` keyword breaks the synchronous flow and creates a new promise handler from every subsequent statement in the function; ...
Read more >
How to use promises - Learn web development | MDN
Inside an async function, you can use the await keyword before a call to a function that returns a promise. This makes the...
Read more >
JavaScript Async - W3Schools
"async and await make promises easier to write" ... Or simpler, since you expect a normal value (a normal response, not an error):...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found