I am still new svelte JS. I am trying to fetch data but getting this error.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.allnigerianewspapers.com.ng/api/news. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 301.
Please, I need a solution.
<script>
import { onMount } from "svelte";
const endpoint = "https://api.allnigerianewspapers.com.ng/api/news";
let posts = [];
onMount(async function () {
const response = await fetch(endpoint);
const data = await response.json();
console.log(data);
});
</script>
<main>
</main>
<style>
/* ommitted for brevity */
</style>