diff --git a/app/Services/getHeadlines.js b/app/Services/getHeadlines.js index 319b7e2..6a67a5b 100644 --- a/app/Services/getHeadlines.js +++ b/app/Services/getHeadlines.js @@ -5,33 +5,23 @@ import { httpAxios, topHeadlines } from "../httpAxios"; // top healines of US export const getHeadlines = async () => { - const response = await httpAxios.get(`/article/getArticles`, { - params: { - action: "getArticles", - keyword: "Top Headlines", - articlesPage: 1, - articlesCount: 100, - articlesSortBy: "date", - articlesSortByAsc: false, - articlesArticleBodyLen: -1, - resultType: "articles", - dataType: ["news", "pr"], - apiKey: key, - forceMaxDataTimeWindow: 31, - }, - }); + const response = await httpAxios.get( + `/mostpopular/v2/emailed/7.json?api-key=${key}` + ); + + console.log("custom response",response) // try to store in firestore -> so we can access it even we are offline - if (response.data.articles.results) { + if (response.data) { try { - response.data.articles.results.forEach(async (article) => { - await addDoc(collection(db, "headlines"), article); - }); + // response.data.forEach(async (article) => { + // await addDoc(collection(db, "headlines"), article); + // }); console.log("Article added to Firestore"); } catch (error) { console.log("error in store db", error); } } - return response.data; + return response.data.results; }; diff --git a/app/components/NewsSwiperSlide.jsx b/app/components/NewsSwiperSlide.jsx index 801e7a3..ab2b28f 100644 --- a/app/components/NewsSwiperSlide.jsx +++ b/app/components/NewsSwiperSlide.jsx @@ -8,6 +8,8 @@ const NewsSwiperSlide = ({ article }) => { const saveDetails = (art) => { localStorage.setItem("details", JSON.stringify(art)); }; + + console.log("img", article.media[0]); return (