CORS prevents fetching data through JavaScript
Closed this issue · 0 comments
rowdyrabouw commented
When you try to retrieve data with JavaScript like in the example below, this will not work because of CORS.
Access to fetch at 'https://api.joind.in/v2.1/talk_comments/44197?format=json' from origin 'http://localhost:8081' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Please alter the response header for these GET requests.
<script>
fetch('https://api.joind.in/v2.1/talk_comments/44197?format=json')
.then((response) => {
console.log(response);
return response.json();
})
.then((json) => {
console.log(json);
});
</script>