Erro when try to link to php


hi guys
i try to build a page to approve a login my code here :
constructor(public nav: NavController, private http: Http ) {
this.nav = nav;
this.http = http;
this.user = {};
this.user.username = ‘’;
this.user.password = ‘’;
this.user.response = ‘’;

   verifylogin(username, password){
    let link = 'xxx/Login.php';
    let user = JSON.stringify({username: this.user.username, password: this.user.password});
, user)
    .subscribe(user => {
        this.user.response =  user._body;
        this.flag = true;
        error => {

        if (this.flag == true)


but i got an erro in this statement :

this.user.response = user._body;

i use ionic 2 type script and i need to send from app user name and password to server side to authenticate and return the response so any adive if i am doing something wrong and even why this error is occur ?

Thank you in advance


Is your server expecting JSON from the request or normal FORM parameters, if it’s the latter case, you’ll probably need

let headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');, 'username=xxx&password=xxx', {headers: headers})


thank you i solved this by chaging this from post to get :slight_smile:


That’s not a solution. It’s extremely insecure and breaks the fundamental principles of REST. Logging a user in absolutely needs to be a POST operation: it is not idempotent, it modifies state, and you are going to end up with cleartext user credentials in browser history and server logs. Very bad.