I am trying to make a cors
PUT request using the vanilla Fetch API
When I click my button to send the PUT request, the method on the first request is OPTIONS
. It is only when I click the button again, then the method on the request changes to PUT
. Why?
I understand this is part of the CORS preflight, but is there a way to trigger the preflight manually so the OPTIONS response can be cached?
Could this behavior be indicative of a failing promise somewhere?
javascript
that you are trying at Question? You could perform the request manually, if, from what can gather, the preflight request is occurring automatically.fetch("url", {method:"OPTIONS"}) .then(response => response.headers) .then(_headers => Array.from(_headers.entries(), h => console.log(h))).catch(err => console.error(err))
, else, from reading of specification, a network error would occur. If from your interpretation the specification is not clear, would suggest searching for a similar issue, or filing an issue at github.com/whatwg/fetch/issues – Lammergeier