I’m new with Ionic and I’m in big doubt.
I have a website login like this:
<form method='POST' action='https://app.astrea.net.br/externalloginservice'>
<input type='text' name='login''></input>
<input type='password' name='pass'></input>
<input type='submit'>Login</input>
</form>
I am making an app in ionic / angular and I want to do this same login, I’ve seen several tutorials and ways to pass a POST, but I can not do, could someone help me?
ps: Sorry my english, I’m not fluent
A form with no explicit enctype
implies a content type of x-www-form-urlencoded
. Using a URLSearchParams
as the body indicates to Angular’s HttpClient
to use that content type:
let body = new URLSearchParams();
body.set("login", login);
body.set("password", password);
http.post("url", body);
Currently my code looks like this
<ion-content ion-padding>
<form (ngSubmit)="logForm()">
<ion-item>
<ion-label position="floating">
<ion-icon name="mail" item-start></ion-icon>
E-mail
</ion-label>
<ion-input color="secondary" type="text" [(ngModel)]="login" name="email" ></ion-input>
</ion-item>
<ion-item>
<ion-label position="floating">
<ion-icon name="lock" item-start></ion-icon>
Senha
</ion-label>
<ion-input color="secondary" type="password" [(ngModel)]="pass" name="pass"></ion-input>
</ion-item>
</form>
<br><br>
<ion-button icon-left size="medium" color="success" type="submit" shape="round" expand="full" (click)="makeLogin()" tappable>
<ion-icon name="log-in"></ion-icon>
Login
</ion-button>
How should makeLogin () function, to perform the action https://app.astrea.net.br/externalloginservice ?