fix(register): fix handling error

This commit is contained in:
Desy Ayurianti 2024-12-12 11:29:03 +07:00
parent 944a9fa5cb
commit 98ca03b55e
2 changed files with 14 additions and 0 deletions

View File

@ -27,6 +27,9 @@ export const httpErrorInterceptor: HttpInterceptorFn = (req, next) => {
case 404:
errorMessage = 'Resource not found: The requested resource does not exist.';
break;
case 422:
errorMessage = 'Enter a different username or email';
break;
case 500:
errorMessage = 'Server error: Please try again later.';
break;

View File

@ -40,6 +40,17 @@ export class RegisterComponent implements OnInit {
this.loading = false;
this.toast.error('Please fill in all fields.');
return;
} else if(this.password.length<8){
this.loading= false;
this.toast.error('Password must be at least 8 characters')
} else if(!this.email.includes('@')){
this.loading=false;
this.toast.error('Invalid Email');
} else {
(error: any) => {
this.loading = false;
this.toast.error(error.error.message);
}
}
const registrationData: RegistrationData = {