I have a server set up and I am using "mssql" npm package to set up the database connections for my query routes. I want just one route in the whole server to be using a different database that is at a different IP address than the rest of the routes.
I have two different configs, configA and configB. This is my route set up:
router.get("/:code", function (req, res) {
var sql = require("mssql");
sql.connect(configA/B, function (err) {
if (err) console.log(err);
var request = new sql.Request();
request.query("some query",
function (err, recordset) {
if (err) console.log(err);
res.send(JSON.stringify(recordset));
}
);
});
});
However, if I go to a page that uses a route with configA and then navigate to a page that uses a route with configB, configA just remains as the config, if that makes sense. I really just want to be able to use configA for routes 1, 2, and 3, and configB for route 4, but I am not able to as it always takes the already existing config.