title: How to use Sql server connection in angular 6?
body: <p>I have do connection in 'Angular6' using <code>sqlserver</code>.</p>
  <p><strong>server.js</strong></p>
  <pre><code>var express = require('express');
  var app = express();
  
  app.get('/', function (req, res) {
     
      var sql = require(&quot;mssql&quot;);
  
      // config for your database
      var config = {
          user: 'abc',
          password: 'abc',
          server: 'servername', 
          database: 'xyz' 
      };
  
      // connect to your database
      sql.connect(config, function (err) {
      
          if (err) console.log(err);
  
          // create Request object
          var request = new sql.Request();
             
          // query to the database and get the records
          request.query('select * from tbl', function (err, recordset) {
              
              if (err) console.log(err)
  
              // send records as a response
              res.send(recordset);
              
          });
      });
  });
  
  var server = app.listen(5000, function () {
      console.log('Server is running..');
  });
  </code></pre>
  <p><strong>data.service.ts</strong></p>
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpClient } from '@angular/common/http';
  
  @Injectable({
    providedIn: 'root'
  })
  export class DataService {
  
  constructor(private http: HttpClient) { }
    getUsers() {
      return this.http.get('https://jsonplaceholder.typicode.com/users')
    }
    getUser(userId) {
      return this.http.get('https://jsonplaceholder.typicode.com/users/'+userId)
    }
  
    getPosts() {
      return this.http.get('https://jsonplaceholder.typicode.com/posts')
    }
  
    getPhotos()
    {
      return this.http.get('https://jsonplaceholder.typicode.com/photos');
    }
  
    getTodos()
    {
      return this.http.get('https://jsonplaceholder.typicode.com/todos');
    }
  }
  </code></pre>
  <p>Right now I have used dummy API'S for result.<br />
  how to get my database results in service?
  I have successfully get result from Sqlserver database.</p>
  <p>I also want to display record in my Component</p>
  <p><strong>user.component.html</strong></p>
  <pre><code>&lt;h1&gt;Users&lt;/h1&gt;
  </code></pre>
  <p>Can I have to import server.js in <code>user.component.ts</code>.<br />
  If yes than how can I do that?</p>