I cant seem to understand why the request is not sent as a POST request My code in NG2 is as follows:
let headers = new Headers({ 'Content-Type': 'application/json'});
let options = new RequestOptions({ headers: headers , method:RequestMethod.Post });
let content = [ { email:email, password: pass } ];
return this._http.post(this._apiPath, content, options).toPromise()
.then(this.extractData)
.catch(this.handleErrorPromise);
(I have coded it using the sample from: http://www.concretepage.com/angular-2/angular-2-http-post-example#example )
within my PHP server i receive the following request:
[15/May/2017:15:09:32 +0000] "OPTIONS /index.php/api/login HTTP/1.1" 404 90 "http://localhost:4200/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
When i run a simple wget request i receive the following correct request in my PHP Server:
[15/May/2017:15:02:51 +0000] "POST /index.php/api/login HTTP/1.1" 200 96 "-" "Wget/1.15 (linux-gnu)" web_1 | 2017/05/15 15:02:51 [info] 15#15: *21 client 172.18.0.1 closed keepalive connection
here is the wget command i use:
wget --post-data "email=myemail@gmail.com&password=test" http://localhost/index.php/api/login
any ideas why does the NG2 doesnt send a POST request? Thanks.