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 (
{ >
diff --git a/app/components/Swiper.jsx b/app/components/Swiper.jsx index 76d69b6..d4e2642 100644 --- a/app/components/Swiper.jsx +++ b/app/components/Swiper.jsx @@ -27,7 +27,8 @@ const SwiperSection = () => { if (isOnline) { try { const response = await getHeadlines(); - setData(response.articles.results); + console.log("response", response); + setData(response); setLoading(false); } catch (error) { console.log(error); diff --git a/app/config/config.js b/app/config/config.js index 99bc4d8..d9d178e 100644 --- a/app/config/config.js +++ b/app/config/config.js @@ -1,5 +1,5 @@ // api end-point -export const api_endpoint = `https://newsapi.ai/api/v1`; +export const api_endpoint = `https://api.nytimes.com/svc`; // our top category export const categorys = [ @@ -21,7 +21,7 @@ export const categorys = [ ]; // key for api -export const key = "7f5fd96a-2f8e-4ac6-9187-cb0e6efc6109"; +export const key = "rANKrRljqAQrCZdtkkuyDz6n4aT3WHAG"; // title export const title = "ENews"