File size: 622 Bytes
0e38302 57a87da 0e38302 57a87da 0e38302 57a87da 0e38302 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | const apiKey = "b029ca9ef3e3419e8ea753449c279def";
function fetchNews(query) {
let url = `https://newsapi.org/v2/everything?q=${query}&apiKey=${apiKey}`;
// ✅ Proxy lagao
let proxyUrl = "https://proxy.corsfix.com/?";
fetch(proxyUrl + url)
.then(res => {
if (!res.ok) {
throw new Error("HTTP Error: " + res.status);
}
return res.json();
})
.then(data => {
console.log("DATA:", data);
displayNews(data.articles);
})
.catch(err => {
console.error("ERROR:", err);
});
} |