title: Express GET Request Results in Error: "res.send is not a function"
body: <p>I am trying to get data from a SQL Server DB using node.  I can make a connection and get data by running functions, but I would like to turn the functions into API endpoints.</p>
  
  <p>Based on the error it seems to me that the <code>res</code> variable isn't getting passed down into the last if statement, but I'm not seeing the issue.</p>
  
  <p>I get a <code>res.send is not a function</code> error when using a <code>GET</code> method on this address from Postman.</p>
  
  <pre><code>let mssqlQuery = function(query, res) {
    sql.connect(dbConfig, function(err) {
      if (err) {
        console.log("Error while connecting database :- " + err)
        res.send(err)
      } else {
        let request = new sql.Request();
        request.query(query, function(err, res) {
          if (err) {
            console.log("Error while querying database :- " + err)
            res.send(err)
          } else {
            res.send(res) // res.send is not a function
          }
        })
      }
    })
  }
  
  // GET API
  app.get("/api/address", function(req, res) {
    var query = "select * from address"
    mssqlQuery(query, res)
  })
  </code></pre>
  
  <p>Is the <code>res</code> variable improperly scoped or might I have the wrong approach entirely?</p>