has been blocked by CORS policy: No 'Access-Control-Allow-Origin' fetch code example
Example 1: Add no cores to fetch
const data = { funny: "Absolutely not", educational: "yas" }
fetch('https://example.com/api/', {
method: 'POST',
mode: 'no-cors',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
}).then(returnedData => {
}).catch(err => {
})
Example 2: Access to fetch at 'https://api.myip.com/' from origin 'http://localhost:8000' has been blocked by CORS policy: No 'Access-
fetch('http://localhost:8080/posts', { mode: 'no-cors' });