P
P
Partizanin2018-04-03 21:17:04
Angular
Partizanin, 2018-04-03 21:17:04

Why isn't an angular 5 http.put request sent?

Why can’t I send a Put request to Angular 5, get works, put doesn’t, although it is sent via postman.

update(user: User) {
    const httpOptions = {headers: new HttpHeaders({'Content-Type': 'application/json',})};
    let url = '/api/' + user.id;

    this.http.put(url, user, httpOptions);
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Partizanin, 2018-04-04
@Partizanin

I figured it out, today I launched the server and the application again and it worked, this is the right decision.
thank you everyone, everyone is free :))
UPD A feature was noticed, there is a suspicion that the problem was that I did not subscribe to the update
, that is, when it was like this.http.put(url, user, httpOptions); that, the request was not sent, and when I added a signature to the answer, like this

this.http.put(url,user,httpOptions).subscribe(data=>console.log(data));
start sending request
update(user: User) { 
    const httpOptions = {headers: new HttpHeaders({'Content-Type': 'application/json',})}; 
    let url = '/api/' + user.id;
    this.http.put(url, user, httpOptions).subscribe(data=>console.log(data));
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question