I need to create a login system, I try to send the params to the PHP server.
Angular app
return this.http.post<any>('/s/login/index.php', {
username: username,
password: password
}).map(user => {
console.log(username);
// login successful if there's a jwt token in the response
if (user) {
// store user details and jwt token in local storage to keep user logged in between page refreshes
}
return user;
});
}
PHP server
if($_SERVER["REQUEST_METHOD"] == "POST"){
// Check if username is empty
if(empty(trim($_POST["username"]))){
$username_err = 'Please enter username.';
$resp->body->message=$username_err;
$resp=json_encode($resp);
echo $resp;
}
But the server always returns
{status: "400", body: {message: "Please enter username."}}