1

Can anybody help to find out what i'm doing wrong here. For every rest calls application calls the Rest APIs twice.

But first request doesn't contains request payload and No response, but both requests give same response status code.

Here is my code.

login(username: string, password: string) {
    const body = { userName: username, password: password };
    this. httpClient.post<User>(this.url, body, { headers: this.header })
    .subscribe( data => {
      return data;
 });

Here is the picture

Gavishiddappa Gadagi
  • 890
  • 1
  • 14
  • 29

1 Answers1

3

HTTP Preflight Request

This a normal behavior. When you attempt to send data to a server using HTTP methods, the browser sends a preflight request, to ensure that the requested resource and other properties are available and allowed on the backend.

Then if the server accepts the request options, the main request is sent. which is why you are seeing two requests.

So your case is pretty normal and expected.

Hamid Asghari
  • 4,954
  • 3
  • 20
  • 32