Code :
async function getNews() {
const response = await fetch('http://newsapi.org/v2/top-headlines?country=in&pageSize=1&apiKey=a876816f98574cdfa23ffdc7d531c7bc');
const jsonResp = await response.json();
return jsonResp;
}
n = await getNews();
Error Shown In Google Chrome Console:
Access to fetch at 'http://newsapi.org/v2/top-headlines?country=in&pageSize=1&apiKey=a876816f98574cdfa23ffdc7d531c7bc' from origin 'chrome-search://local-ntp' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
GET http://newsapi.org/v2/top-headlines country=in&pageSize=1&apiKey=a876816f98574cdfa23ffdc7d531c7bc net::ERR_FAILED getNews @ VM88:2 (anonymous) @ VM94:1
Uncaught TypeError: Failed to fetch