Created
October 24, 2020 19:57
-
-
Save simonjcarr/08118a8bbe53035c92bb7c715d5834f5 to your computer and use it in GitHub Desktop.
async-await_promise_correct
This file contains hidden or 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((resolve, reject) => { | |
(async () => { | |
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