Hi,
I am using the sample code given for promises and it looks something like this -
sql.connect(sqlConfig).then(pool => {
return pool.request()
.query(currentAssignment)
}).then(result => {
console.log(result)
return pool.request()
.query(activeAssignment)
}).then(result => {
console.log(result)
return pool.request()
.query(recentAssignment)
}).then(result => {
console.log(result)
})
I am getting error ReferenceError: pool is not defined is there any thing else i need to do for this to work.
Thanks & Regards
Did you deal width this issue, I have this problem too.
Solved it by doing this:
const sql = require('mssql')
const pool = new sql.ConnectionPool(config/string)
pool.connect().then(() => {
return pool.request().query(`....`)
}).then(result => {
return pool.request().query(`other query...`)
})
etc. etc.
@jeetendra-choudhary
You're getting the that pool is not defined error because.... the pool variable is not defined :P
You define pool variable in the anonymous function on line 1, but that variable's scope ends at line 4 (with the closing }). When you try to access that variable on line 6, it throws the error.
Most helpful comment
Solved it by doing this:
etc. etc.