Boa tarde galera,
estou seguindo o curso, de Angular parte 2: Autenticação, Forms e lazy loading,
na parte de criar validador assíncrono tive um problema,
segue o erro do console:
Failed to load resource: the server responded with a status of 404 (Not Found)
ERROR HttpErrorResponseerror: {message: "route /user/existis/sds does not exists!"}
message: "route /user/existis/sds does not exists!"
__proto__: Objectheaders:
HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
message: "Http failure response for http://localhost:3000/user/existis/sds: 404 Not Found"
name: "HttpErrorResponse"ok: falsestatus: 404statusText: "
Not Found"url: "http://localhost:3000/user/existis/sds"__proto__: HttpResponseBase
defaultErrorLogger @ core.js:1598
A minha API esta sendo executada, e retorna o seguinte json no caminho
{
message: "route /user/existis/sds does not exists!"
}
Segue meu singup.component.ts :
@Component({
selector: 'ap-singup',
templateUrl: 'signup.component.html',
styleUrls: ['singup.component.css']
})
export class SingUpComponet implements OnInit {
singupForm: FormGroup;
constructor(
private userNotTakenValidatorService: UserNotTakenValidatorService,
private formBuilder: FormBuilder) { }
ngOnInit(): void {
this.singupForm = this.formBuilder.group({
email: ['',
[
Validators.required,
Validators.email
]
],
fullName: ['',
[
Validators.required,
Validators.minLength(2),
Validators.maxLength(50)
]
],
userName: ['',
[
Validators.required,
Validators.minLength(2),
Validators.maxLength(30),
lowerCaseValidator,
Validators.pattern(/[a-z0-9_\-]+$/)
],
this.userNotTakenValidatorService.checkUserNameTaken()
],
password: ['',
[
Validators.required,
Validators.minLength(8),
Validators.maxLength(14)
]
]
});
}
}
segue o meu template:
...
<div class="form-group">
<input formControlName="userName" placeholder="user name" class="form-control">
<ap-vmessage *ngIf="singupForm.get('userName').errors?.required" text="userName is required">
</ap-vmessage>
<ap-vmessage *ngIf="singupForm.get('userName').errors?.minlength" text="Minimun length is 2">
</ap-vmessage>
<ap-vmessage *ngIf="singupForm.get('userName').errors?.maxlength" text="Max length is 30">
</ap-vmessage>
<ap-vmessage *ngIf="singupForm.get('userName').errors?.lowerCase" text="must be lower case">
</ap-vmessage>
<ap-vmessage
*ngIf="singupForm.get('userName').errors?.userNameTaken"
text="UserName already taken">
</ap-vmessage>
<small *ngIf="singupForm.get('userName').valid" class="text-success" >User avaliable</small>
</div>
...
Quando uso o input userName no template aparece erro 404 no console, com o json acima, acredito que o erro seja na API.