I have a function in this way
function con(){
database.connect(con, (err, con) => {
conn.query("select * from person", (err, rs) => {
console.log(rs)--->result
return rs
})
}
}
var val = con()
console.log(val) // --> Undefined
After lot of searching came to know we cant return a value from callback.Done this
function con(fn){
database.connect(con, (err, con) => {
conn.query("select * from person", (err, rs) => {
console.log(rs) // --> result
fn(rs)
})
}
}
var val = con(function(rs) {
console.log(rs) // --> result
return rs
})
console.log(val) // --> Again undefined
I want to use the rs in another method and should return it in the resolver of the graphql How to return the value from the above and use it in another function