mirror of
https://github.com/abrendan/smolNews.git
synced 2025-06-16 20:55:03 +02:00
Cleaned the API key declaration
This commit is contained in:
parent
cf5caf291e
commit
7ba95a157a
18
script.js
18
script.js
@ -1,3 +1,6 @@
|
|||||||
|
const apiKeyCurrents = 'b2uZWPY42BaUWN4Luaj_fbjJR6y7idTudew9UcpSbzr2D2VO';
|
||||||
|
const apiKeyNYT = 'NQdorI46QZM3Kythn8ymAWID8ojT7ntY';
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
configureDropdowns();
|
configureDropdowns();
|
||||||
fetchNewsArticles();
|
fetchNewsArticles();
|
||||||
@ -13,8 +16,7 @@ document.getElementById('searchButton').addEventListener('click', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function fetchTopics() {
|
function fetchTopics() {
|
||||||
const apiKey = 'b2uZWPY42BaUWN4Luaj_fbjJR6y7idTudew9UcpSbzr2D2VO';
|
const url = `https://api.currentsapi.services/v1/available/categories?apiKey=${apiKeyCurrents}`;
|
||||||
const url = `https://api.currentsapi.services/v1/available/categories?apiKey=${apiKey}`;
|
|
||||||
|
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
@ -78,8 +80,7 @@ function configureDropdowns() {
|
|||||||
|
|
||||||
// Fetch available languages from the Currents API
|
// Fetch available languages from the Currents API
|
||||||
function fetchLanguages() {
|
function fetchLanguages() {
|
||||||
const apiKey = 'b2uZWPY42BaUWN4Luaj_fbjJR6y7idTudew9UcpSbzr2D2VO';
|
const url = `https://api.currentsapi.services/v1/available/languages?apiKey=${apiKeyCurrents}`;
|
||||||
const url = `https://api.currentsapi.services/v1/available/languages?apiKey=${apiKey}`;
|
|
||||||
|
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
@ -105,8 +106,7 @@ function fetchLanguages() {
|
|||||||
|
|
||||||
// Fetch available countries from the Currents API
|
// Fetch available countries from the Currents API
|
||||||
function fetchCountries() {
|
function fetchCountries() {
|
||||||
const apiKey = 'b2uZWPY42BaUWN4Luaj_fbjJR6y7idTudew9UcpSbzr2D2VO';
|
const url = `https://api.currentsapi.services/v1/available/regions?apiKey=${apiKeyCurrents}`; // New API link for regions
|
||||||
const url = `https://api.currentsapi.services/v1/available/regions?apiKey=${apiKey}`; // New API link for regions
|
|
||||||
|
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
@ -147,8 +147,7 @@ function fetchNewsArticles() {
|
|||||||
|
|
||||||
// Fetch news articles from the Currents API
|
// Fetch news articles from the Currents API
|
||||||
function fetchFromCurrentsAPI(query, source, topic, language, region) {
|
function fetchFromCurrentsAPI(query, source, topic, language, region) {
|
||||||
const apiKey = 'b2uZWPY42BaUWN4Luaj_fbjJR6y7idTudew9UcpSbzr2D2VO';
|
let url = `https://api.currentsapi.services/v1/search?apiKey=${apiKeyCurrents}`;
|
||||||
let url = `https://api.currentsapi.services/v1/search?apiKey=${apiKey}`;
|
|
||||||
|
|
||||||
if (query) {
|
if (query) {
|
||||||
url += `&keywords=${encodeURIComponent(query)}`;
|
url += `&keywords=${encodeURIComponent(query)}`;
|
||||||
@ -185,8 +184,7 @@ function fetchFromCurrentsAPI(query, source, topic, language, region) {
|
|||||||
|
|
||||||
// Fetch news articles from the New York Times API
|
// Fetch news articles from the New York Times API
|
||||||
function fetchFromNYTAPI(query, topic) {
|
function fetchFromNYTAPI(query, topic) {
|
||||||
const apiKey = 'NQdorI46QZM3Kythn8ymAWID8ojT7ntY';
|
let url = `https://api.nytimes.com/svc/search/v2/articlesearch.json?api-key=${apiKeyNYT}`;
|
||||||
let url = `https://api.nytimes.com/svc/search/v2/articlesearch.json?api-key=${apiKey}`;
|
|
||||||
|
|
||||||
if (query) {
|
if (query) {
|
||||||
url += `&q=${encodeURIComponent(query)}`;
|
url += `&q=${encodeURIComponent(query)}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user