private headers = new Headers({'Content-Type': 'application/json'});
private url = 'localhost:3000/users/register';
constructor(private http: Http) { }
registerEmail(link:string , email: string , password: string): Promise<any>
{
return this.http
.post(this.url, JSON.stringify({email: email , password: password}), {headers: this.headers})
.toPromise()
.then(res => res.json().data)
.catch(this.handleError);
}
Use postman to request to display the post request normally
What host are you running the POST request from? Angular will have an Options when making cross-domain requests, which seems to check whether cross-domain is allowed. In my current project, the front-end and back-end domain names are different, so Options and Request appear at the same time, which was not the case when they used the same domain name.