@NthabyMogoboya wrote:
service.ts
private _adminLogin =“http://localhost:4000/admin_login”;
adminLogin(admin){
return this.httpClient.post(this._adminLogin,admin);
}login.ts
login: any;
loginUserData = {
email_address: “”,
password: “”
};
constructor(private alertService: AlertService,private cartService: CartService,private router: Router) { }
ngOnInit() {
}
async signIn(){
if(this.loginUserData.email_address ==""){
this.alertService.presentToast(“Provide email”);
}else if(this.loginUserData.password ==""){
this.alertService.presentToast(“Provide password”);
}
this.cartService.adminLogin(this.loginUserData).subscribe(
_data => {
this.alertService.presentToast(“Logged In”);
},
error => {
console.log(error);
},
() => {
this.router.navigate([‘home’]);
}
);
}login.html
<form method="POST" (ngSubmit)="login(form)"> <ion-grid > <ion-row class="cardconteudo" class="ion-justify-content-center"> <ion-col class="ion-align-self-center" size-md="6" size-lg="5" size-xs="12" color="transparent"> <div class="ion-padding" > <ion-item> <ion-input [(ngModel)]="loginUserData.email_address" name="email_address" type="text" placeholder="Username/Name@email.com"></ion-input> </ion-item> <ion-item> <ion-input [(ngModel)]="loginUserData.password" name="password" type="password" placeholder="Password"></ion-input> </ion-item> </div> <div class="ion-padding"> <ion-button block (click)="signIn()">Login</ion-button> </div> </ion-col> </ion-row> </ion-grid> </form>
I get this error when I click the login button
What is wrong with my code?
Posts: 1
Participants: 1