Created
October 24, 2020 19:49
-
-
Save simonjcarr/89477a4cb90ec0ef28b24536f2feba37 to your computer and use it in GitHub Desktop.
async/await promise anti-pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMessages() { | |
return newPromise(async (resolve, reject) => { | |
try { | |
let results = await db.query("select * from messages") | |
return resolve(results) | |
} catch (err) { | |
return reject(err) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the article! There's a small typo in the code, I think: