I am trying to make a POST call using HttpClient
in an Angular 5 project, and I want to set the header:
import { HttpClient, HttpHeaders, HttpRequest } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { AuthData } from './models/auth-data';
@Injectable()
export class AuthService {
constructor(private http: HttpClient) { }
auth = (data: AuthData) => {
var url = "https://.../login";
var payload = data;
var headers = new HttpHeaders().set('Content-Type', 'application/json; charset=utf-8');
var options = {
headers: headers
};
this.http.post(url, payload, options).subscribe();
}
}
For some reason, the Content-Type
header does not seem to be in the request I am making.
Why is this?
Observable
not aSubscription
. – Benniebenningchange
, what does change mean, change from what to what? :) – Slovenia