JSFiddle - React, Tailwind, and code Playground
by kontrach
HTML
<button>Fetch</button>
JavaScript
const jsonUrl = 'https://s3-us-west-2.amazonaws.com/reuters.medals-widget/medals.json';
document.querySelector('button').addEventListener('click', () => {
var a = fetch(jsonUrl, {
method: 'GET',
mode: 'no-cors',
headers: new Headers(
{"Content-Type": "application/json",
"Accept":"application/json"}
)
});
console.log('fetch', a);
a.then(r => {console.log(r); document.body.innerHTML = 'Hello';}).catch(e => {console.log('error', e), document.body.innerHTML = e;});
})