I have a code snippet below where I am trying to query the backend to check if an email is already registered or not. However, no matter what email address I pass to the verifyEmail function, the "registered" variable always remains false. How can I update the "registered" variable based on the response from the backend? Thank you.
export class MyClass {
registered: boolean = false;
message: string = ''
verifyEmail(email) {
this.registered= false
let verifyEmailUrl = "/backend/GetUserByEmail";
this.http.post(verifyEmailUrl, {
email: email
}).subscribe(
(data) => {
if (data["user"]) { // can find a user
this.message = 'This email has already been registered'
this.registered= true
}
});
}