javascript - pass values from mssql to views in node -


being new node js , javascript . have been trying find solution problem .

this app.js file

var express=require ('express'); var bodyparser = require('body-parser'); var path = require ('path'); var sql = require('mssql');  var app = express();  const config = {     user: 'sa',     password: 'password',     server: 'localhost\\sqlexpress', // can use 'localhost\\instance' connect named instance      database: 'pcgdb',      options: {         encrypt: false // use if you're on windows azure              }     };  const request = new sql.request()  //view engine app.set('view engine', 'ejs'); app.set('views', path.join(__dirname, 'views'))  app.use(bodyparser.json()); app.use(bodyparser.urlencoded({extended: false}));  app.get('/',function(req,res){    res.render('index') });  app.get('/new_project', function(req, res) {     function(data,err){        var data= request.query('select project_type_desc project_type');        //not sure should go here !!  app.listen(3000,function(){     console.log ('server listening on port 3000') }) 

my problem : trying query database(ms sql server) has project type table project_type_description column. , pass view serve values dropdown . have 10 other tables have query values 10 other dropdowns (please clue me how accomplish ). view trying pass /new_project. way try not working , please .

thanks

return response.

app.get('/new_project', function(req, res) {  function(data,err){    var data= request.query('select project_type_desc                             project_type');    return res.status(200).send(data);  } }); 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -