| 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); | |
| }); | |
| } |