Can i creat a login function like this.below my code

 this.http.get("http://xxx/xx/xx/xx/index.php/Login/"+this.username+"/"+this.password, options)
 
  .subscribe(data => {
    this.data = data.json();
    let response = this.data.code;
    alert(response);
   if(response=="200")
    {
    	alert("You have successfully logged In !");
       this.navCtrl.setRoot(WelcomePage);

    }else if(response=="401")
    {
    	alert("Incorrect password or email");
    }
  }, error => {
    //console.log(error);// Error getting the data
    alert("No Internet connection!")
  });

What’s your question? Does it work when you run it?

@AaronSterling its working fine.actually i want to know this is the right way to login functionality.

“Right” has a subjective component to it, but here is how I handle authentication. I prefer to decouple the act of logging in from the reaction to having logged in. I find this more flexible, because it makes it easier to handle cases where logging in and out is done in many ways, such as retrieving stored authentication tokens from storage, which does not interact with the backend at all, but the rest of the app that presents authenticated content should not have to concern itself with that.

@rapropos thank you so much.