aass / script.js
abeea's picture
Update script.js
57a87da verified
raw
history blame contribute delete
622 Bytes
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);
});
}