title: How do I pass user name and password in an http post request from angular 4
body: <p>I need to send username and password to a login api using angular http post request. Here is my code:</p>
  
  <pre><code>const params = new URLSearchParams();
      params.set('username', username);
      params.set('password', password);
      this.headers = new Headers({ 'content-type': 'application/x-www-form-urlencoded', 'authorization': 'Basic' });
      this.options = new RequestOptions({headers: this.headers, method: RequestMethod.Post, params: params });
      return this.http.post(this.config.baseUrlAuthSvc + this.config.login, this.options)
          .map((response) =&gt; { return response; })
  </code></pre>
  
  <p>I am getting the following error in response:</p>
  
  <blockquote>
    <p>Request URL:<a href="http://111.22.333.44:55/api/token" rel="nofollow noreferrer">http://111.22.333.44:55/api/token</a>
    Request Method:OPTIONS
    Status Code:400 Bad Request
    Remote Address:172.31.131.13:85
    Referrer Policy:no-referrer-when-downgrade</p>
  </blockquote>
  
  <p>Am I missing something?</p>