The below code is angular2 form submission code,i am sending a test username and password
logForm(formData){
console.log('Form data is ', formData.title);
var link = 'http://test/index.php/api/userAuth';
var headers = new Headers();
headers.append("Content Type","application/json");
var data = JSON.stringify({
username:'user',
password:'user123'
});
this.http.post(link,data,headers)
.subscribe(data => {
console.log(data.json());
});
}
The PHP side is in codeigniter using REST architecture, php code is given below
function userAuth_post() {
if (($this->post('username') == '') || ($this->post('password') == '')) {
$this->response(array('message' => 'Network Error! Try Again!!!'), 200);
}else{
$this->response(array('message' => 'Success'), 200);
}
}
Now i am receiving "Network Error! Try Again!!!", i should be getting "Success".