JSFiddle - React, Tailwind, and code Playground
HTML
<button id="a">Fetch w headers - OPTIONS</button>
<button id="b">Fetch w/o headers - no OPTIONS</button>
JavaScript
$('#a').click(function(){
fetch('https://jsonplaceholder.typicode.com/posts', {
method: 'get',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
}
}).then(res=>res.json())
.then(function(res) {
console.log(res);
});
})
$('#b').click(function(){
fetch('https://jsonplaceholder.typicode.com/posts', {
method: 'get',
}).then(res=>res.json())
.then(function(res) {
console.log(res);
});
})