title: Angular 6 httpClient Post with credentials
body: <p>I have some code which posts some data to create a data record.</p>
  
  <p>It's in a service:</p>
  
  <p>Here's the code:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpClient, HttpHeaders } from '@angular/common/http';
  
  const httpOptions = {
    headers: new HttpHeaders({ 'Content-Type': 'application/json' })
  };
  
  @Injectable({
    providedIn: 'root'
  })
  export class ApiService {
  
    constructor(private http: HttpClient) { }
  
    create() {
        const postedData = { userid: 1, title: 'title here', body: 'body text' };
        return this.http.post('https://jsonplaceholder.typicode.com/posts', postedData, httpOptions).subscribe(result =&gt; {
          console.log(result);
        }, error =&gt; console.log('There was an error: '));
    }
  
  }
  </code></pre>
  
  <p>My question is...what do I do what the url requires from the user to be logged in...How do I pass the credentials?</p>