Failed to load resource: 3000/photos/undefined/comments:1 the server responded with a status of 500 (Internal Server Error) Estou recebendo esse erro ao clicar no botão para adicionar um comentário. o botao está com o event binding de submit para chamar o método save()
save() {
const comment = this.commentForm.get('comment').value as string;
this.photoService
.addComment(this.photoId, comment)
.subscribe( () => {
this.commentForm.reset();
alert('comentario adicionado');
});
}
<div class="mt-4">
<form [formGroup]="commentForm" (submit)="save()">
<div class="input-group">
<textarea formControlName="comment" class="form-control"></textarea>
<div class="input-group-append">
<button [disabled]="commentForm.invalid" class="btn btn-primary pull-left">Publish</button>
</div>
</div>
<ap-vmessage
*ngIf="commentForm.get('comment').errors?.maxlength"
text="Length must be only up to 300">
</ap-vmessage>
</form>
</div>
</div>
<div>
addComment (photoId: number, commentText: string) {
return this.http.post(API + '/photos/' + photoId + '/comments', { commentText: commentText });
}