1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Angular HTTP POST request not sent in service method, but no error shown in console

Discussão em 'Angular' iniciado por user28273827332, Outubro 3, 2024.

  1. I have a service with 2 functions:

    createCourse(course: Course): Observable<Course> {
    return this.http.post<Course>(`${this.apiUrl}/courses/add`, course);
    }


    and

    createAuthor(name: string): Observable<Author> {
    console.log(`${this.apiUrl}/authors/add`);
    console.log({ name: name });
    return this.http.post<Author>(`${this.apiUrl}/authors/add`, { name: name });
    }


    they are made according to the swagger, the swagger for the second function is:

    http://localhost:4000/authors/add


    The problem is that when I invoke it, the request for the createAuthor method doesnt get sent, and i got no error. The first function- create Course works fine, but the second doesnt send a request (?). The console logs are fine:

    http://localhost:4000/authors/add
    Object { name: "Jo" }


    But theres no request being sent. Why it is so? How to fix it? Why one function work and second doesnt work?

    Continue reading...

Compartilhe esta Página