ChiakiYu
ChiakiYu

Reputation: 965

The angular http request is sent twice at the same time

I used angluar4 http, Such as login request server, When I click the button to submit the form, Google Chrome's network to capture the two requests, one of which is zone.js: 2744 (the return of the data is wrong).

Why is there twice?

My code reference here: https://angular.cn/tutorial/toh-pt6

1 all 2 first 3 second

Upvotes: 4

Views: 2383

Answers (1)

PiniH
PiniH

Reputation: 1941

https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request

You are seeing the OPTIONS call first - which is a call the browser does automatically (in certain conditions) when requesting data from a different origin (server) than what you served the html from.

Upvotes: 6

Related Questions