D
D
dicem2020-01-23 16:56:14
AJAX
dicem, 2020-01-23 16:56:14

Why is a GET request converted to OPTIONS in axios?

The essence is as follows, there is an api on the server, an application on vue and a method that sends a request:

getCartInfo({cartToken} = {}) {
    return axios.get(`${apiURL}/order/cart`, {
      headers: {
        'cartToken': cartToken
      }
    })
  }

The URL and token enter the method validly, I checked the console with a log.
The request is converted to OPTIONS and the headers that I wrote for some reason was not assigned, and the 'cartToken' key in lower case went to Access-Control-Request-Headers.
5e29a58e5a00e012493356.png
5e29a59821173115330483.png
Well, accordingly, without the necessary header, the request returns 404.
I checked everything in postman, the API works without problems, but it’s a real disaster at the front.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2020-01-23
@dicem

https://developer.mozilla.org/en/docs/Web/HTTP/CORS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question