1

I'm using axios whenever I call API it would be called twice as I see in network in chrome devtools
in the devtool and in the header of the network first one's header looks like this which I don't recognize the content specially the part of request method

Request URL: "MY URL"
Request Method: OPTIONS //i'm confused in here 
Status Code: 204 

the example above has no success for sending request

but this one is the one which has a successful request

Request URL:'MY URL'
Request Method: POST
Status Code: 200  
joseph smith
  • 101
  • 7
  • 1
    Does this answer your question? [why axios get method request send twice?](https://stackoverflow.com/questions/55823110/why-axios-get-method-request-send-twice) – Aydin K. Jan 14 '21 at 13:33
  • There's a good explaination of what options requests are here: https://stackoverflow.com/questions/29954037/why-is-an-options-request-sent-and-can-i-disable-it – mikat Jan 14 '21 at 13:35
  • I recommend you to look for how OPTIONS request works, but basically it's a request to ask to the server if your request can be made. In you case, it will ask the server if the route "/Auth/Checkcode" can receive a POST request. – Artur Nista Jan 14 '21 at 13:35
  • This is normal ; the first request is a **pre-flight request** that is sent automatically by the browser, to ask the server if it is okay to send the real request. The server will response with various HTTP headers that describe which requests are allowed. This happens usually for [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), when your request is sent to another domain. https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS – ojathelonius Jan 14 '21 at 13:37
  • thanks a lot... – joseph smith Jan 14 '21 at 14:28

0 Answers0