Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Promise in nodejs
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
You can’t perform that action at this time.