title: Applying request headers angular 6
body: <p>I'm fairly new to <code>angular</code> and I'm using the latest version.  </p>
  
  <p>I am trying to execute a post request but I run into <code>CORS</code> issue. I believe the problem is because I don't have a content type in my request header and I want to add that to my code.  </p>
  
  <p>In previous version, this method below worked but not anymore.  What do I have to do to apply headers correctly in <code>Angular 6</code>?  </p>
  
  <p>I get the following error </p>
  
  <blockquote>
    <p>"Argument of type '{ header: any; }' is not assignable to parameter of type 'RequestOptionsArgs'."</p>
  </blockquote>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { environment } from '../environments/environment';
  
  import { User } from './user';
  import { Http } from '@angular/http';
  import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
  import { Observable } from 'rxjs';
  import { map, catchError } from "rxjs/operators";
  
  
  
  const API_URL = environment.apiUrl;
  
  @Injectable({
    providedIn: 'root'
  })
  export class ApiService {
  
    constructor(private http: Http) {
  
    }
  
    public createUser(user: User): Observable&lt;User&gt; {
      let getHeaders: HttpHeaders = new HttpHeaders({
        'Content-Type': 'application/json'
      });
      return this.http
       .post(API_URL + '/users', user, {header: getHeaders}).pipe(
          map(response =&gt; {
            return new User(response.json());
          }), catchError(this.handleError)
        )
    }
  </code></pre>