I need help with angular, I have a method that makes the verification whether the email already exists or not.
This code is responsible for this:
emailExists = (email) => this.http.post(`${this.BASE_URL}/emailExists`, { 'email': email }).subscribe(response => {
if (!response.json())
return false
this.handleError("Email already exists!")
return true
}, error => this.handleError(error.json()))
This is who calls the method:
const emailValid = (auth) =>
control => {
var a = auth.emailExists(control.value)
var b = (/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/).test(control.value)
if (!a && b)
return null
else
return { invalidEmail: true }
}
It is noticeable that the code responsible for it returns true or false depending on the originality of the email, but who is calling this method is getting a Subscriber, where am I wrong?
Any additional information I will be making available.
EDIT: I couldn't get the answer in the linked duplicate, i've tried everything of that duplicate, nothing worked...