Skip to content

Instantly share code, notes, and snippets.

@simonjcarr
Created October 24, 2020 19:49
Show Gist options
  • Save simonjcarr/89477a4cb90ec0ef28b24536f2feba37 to your computer and use it in GitHub Desktop.
Save simonjcarr/89477a4cb90ec0ef28b24536f2feba37 to your computer and use it in GitHub Desktop.
async/await promise anti-pattern
function getMessages() {
return newPromise(async (resolve, reject) => {
try {
let results = await db.query("select * from messages")
return resolve(results)
} catch (err) {
return reject(err)
}
})
}
@TimothyJones
Copy link

Thanks for the article! There's a small typo in the code, I think:

-  return newPromise(async (resolve, reject) => {
+  return new Promise(async (resolve, reject) => {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment