Answers for "fetch mode no cors"

-1

fetch request allow cors

// From http://foo.com/
fetch('http://bar.com/data.json', { 
    mode: 'no-cors' // 'cors' by default
}).then(function(response) {
    // Do something with response
});
Posted by: Guest on June-25-2021
19

fetch api javascript

fetch('http://example.com/movies.json')
  .then((response) => {
    return response.json();
  })
  .then((myJson) => {
    console.log(myJson);
  });
Posted by: Guest on February-10-2020
0

et the request's mode to 'no-cors' to fetch the resource with CORS disabled

var proxyUrl = 'https://cors-anywhere.herokuapp.com/',
    targetUrl = 'http://catfacts-api.appspot.com/api/facts?number=99'
fetch(proxyUrl + targetUrl)
  .then(blob => blob.json())
  .then(data => {
    console.table(data);
    document.querySelector("pre").innerHTML = JSON.stringify(data, null, 2);
    return data;
  })
  .catch(e => {
    console.log(e);
    return e;
  });
Posted by: Guest on February-05-2021
4

fetch suntax

fetch('http://example.com/movies.json')
  .then((response) => {
    return response.json();
  })
  .then((data) => {
    console.log(data);
  });
Posted by: Guest on March-16-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language