Forgive me if this is a basic question. I'm a seasoned developer in other languages, but just starting with Node.js and trying to run my very first query using mssql.
I followed your Config and Async/Await example almost exactly, but I get an error
D:\NodeJS\dbtest.js:14
(async function () {
^
TypeError: (intermediate value)(intermediate value)(intermediate value)(intermediate value)(intermediate value) is not a function at Object.
14:1)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
const sql = require('mssql');
const config = {
user: process.env.DB_USER,
password: process.env.DB_PASS,
server: process.env.DB_HOST,
database: 'myDB',
options:{
encrypt: false
}
}
(async function () {
try{
let pool = await sql.connect(config)
let qry_getPlayers = await pool.request()
.query("SELECT * FROM players p WHERE p.event_id = 5188")
console.dir(qry_getPlayers)
}
catch(err){
console.log(err)
}
})()
sql.on('error', err => {
console.log(err)
})
Put the symbol ; at the end of your lines. That way Javascript has no questions about where you mean to end a command. Doing that on my end when I had the same error fixed it for me.
` const config = {
user: process.env.DB_USER,
password: process.env.DB_PASS,
server: process.env.DB_HOST,
database: 'myDB',
options:{
encrypt: false
}
} ; // insert symbol ; here`
some suggestions have been given to resolve the problem without response.
closing due to lack of response from author
Most helpful comment
Put the symbol ; at the end of your lines. That way Javascript has no questions about where you mean to end a command. Doing that on my end when I had the same error fixed it for me.