Reputation: 1976
So I'm running into a similar situation with sending an Http.post in Angular as this. However, I do have the Header class imported, and I am still getting the text/plain ContentType first. Here is what I have:
import { Component } from '@angular/core';
import { Http, Headers } from '@angular/http';
import {User} from "../classes/user";
@Component({
selector: 'login',
templateUrl: 'frontend/login/view.html',
styleUrls: ['frontend/login/style.css'],
})
export class LoginComponent {
email: string;
emailError: boolean = false;
password: string;
passwordError: boolean = false;
persist: boolean;
user: User;
constructor(
private _http: Http
) { }
login() {
var headers = new Headers();
headers.append('ContentType', 'application/json');
this.emailError = !this.email;
this.passwordError = !this.password;
if (this.emailError || this.passwordError) { return; }
this._http.post('http://localhost:81/login', JSON.stringify({username: this.email, password: this.password}), { headers: headers })
.map(res => res.json())
.subscribe(
user => this.user = user
);
}
}
Anyone know if there's a way to strip this header? or is this possible something that Chrome is doing on it's own?
Upvotes: 0
Views: 612
Reputation: 1976
Welp, I'm an idiot...
'Content-Type'
not
'ContentType'
Helps if I use the right header...I'll go bang my head against a wall now.
Upvotes: 1