title: Angular2: Angular-http RequestOptions confusion
body: <p>I'm busy with my first Angular web app, I have to do a post and I'm very unsure how to add the headers to the request...  As far as I've read online the way to do this is by using angular-http's RequestOptions.  I see many examples online where RequestOptions is used in this way:</p>
  
  <p>My code:</p>
  
  <pre><code>let hdrs = new Headers({ 'Content-Type': 'application/json' });
    let options = new RequestOptions({headers: hdrs});
          return this.http.post(this.API_URL + "StockTake/AddToStockTake", JSON.stringify(stockTakeModel), options)
          .map((res: Response) =&gt; res.json())
          .catch((error: any) =&gt; Observable.throw(error.json().error || 'server error'));
    }
  </code></pre>
  
  <p>When I do this I always get the same error in my chrome console,</p>
  
  <p>Chrome error:</p>
  
  <pre><code>  Failed to load resource: net::ERR_CONNECTION_RESET
  </code></pre>
  
  <p>In Firefox the error is:  </p>
  
  <pre><code>[WDS] Disconnected!
  main.bundle.js:51863:10
  log
  http://localhost:4200/main.bundle.js:51863:10
  onSocketMsg.close
  http://localhost:4200/main.bundle.js:51912:3
  socket/sock.onclose
  http://localhost:4200/main.bundle.js:85690:4
  EventTarget.prototype.dispatchEvent
  http://localhost:4200/main.bundle.js:51108:5
  SockJS.prototype._close/&lt;
  http://localhost:4200/main.bundle.js:83235:5
  Zone$1&lt;/ZoneDelegate&lt;/ZoneDelegate.prototype.invokeTask
  http://localhost:4200/main.bundle.js:86029:21
  Zone$1&lt;/Zone&lt;/Zone.prototype.runTask
  http://localhost:4200/main.bundle.js:85918:28
  ZoneTask/this.invoke
  http://localhost:4200/main.bundle.js:86099:28
  scheduleTask/data.args[0]
  </code></pre>
  
  <p>It's been suggested to me that the third option of the http post method takes a RequestOptionsArgs type and not a RequestOptions type...  If so how would that look in this instance?  I've also tried <code>{ headers: hdrs }</code> instead of options as the third argument but still getting the same error...</p>
  
  <p>I'm not sure if I'm looking in the right place for my issue, when I look under the request headers of the request in Chrome dev tools Networking tab it lists the following:</p>
  
  <pre><code>Provisional headers are shown
  Access-Control-Request-Headers:
  content-type
  Access-Control-Request-Method: POST
  Origin: http://localhost:4200
  Referer: http://localhost:4200/stockTake
  User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
  </code></pre>
  
  <p>I can post to the API using the Insomnia Rest client so I know the issue isn't API related...</p>
  
  <p>the Online places I've seen RequestOptions used the way I do use it:</p>
  
  <p><a href="https://scotch.io/tutorials/angular-2-http-requests-with-observables" rel="nofollow noreferrer">https://scotch.io/tutorials/angular-2-http-requests-with-observables</a></p>
  
  <p><a href="https://angular.io/docs/ts/latest/guide/server-communication.html" rel="nofollow noreferrer">https://angular.io/docs/ts/latest/guide/server-communication.html</a></p>