POST request returns 500 error, however backend works fine- angular

Discussão em 'Angular' iniciado por Beth McCoy, Fevereiro 10, 2025.

  1. Beth McCoy

    Beth McCoy Guest

    So i'm currently trying to set up a post request to allow users to upload comments via my Angular API however, I'm getting a 500 error. I have tested the backend API POST request on postman and it works completely fine. This is the error I'm getting: "POST http://localhost:5000/api/v1.0/events/undefined/discussions/undefined/replies 500 (INTERNAL SERVER ERROR)"

    Bellow is PostReply in the Web Service:

    postReply(reply: any) {
    let postData = new FormData();
    postData.append('username', reply.username);
    postData.append('comment', reply.comment);

    return this.http.post(
    'http://localhost:5000/api/v1.0/events/' + this.eventID + '/discussions/' + this.discussionId + '/replies',
    postData
    );


    The onSubmit function:

    onSubmit() {
    this.webService.postReply(this.replyForm.value)
    .subscribe((response: any) => {
    this.replyForm.reset();
    this.replies = this.webService.getReplies(this.route.snapshot.params['id'],this.route.snapshot.params['_id']);
    });

    Continue reading...

Compartilhe esta Página