Last active
September 2, 2018 21:48
-
-
Save andersonmendesdev/a3b9e231d71049ea1727341905ae25d5 to your computer and use it in GitHub Desktop.
Promise in nodejs
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
const selectDate = (connection, id) => { | |
return new Promise ((resolve, reject) => { | |
connection.query('select * from cliente where codcliente = '+id, (err, result) => { | |
if(err){ | |
reject(err) | |
}else{ | |
resolve(result) | |
} | |
}) | |
}) | |
} | |
const myfunction = async() => { | |
console.log('before') | |
const data = await selectDate(connection, id) | |
console.log('after date= '+data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment