atiqueahmedziad / news-search-web-app

News Search Web Application presents news from different news sources and blogs all over the internet.
https://newsapiwebapp.herokuapp.com
1 stars 2 forks source link

Fetch news sources from Sources endpoint in API #1

Open atiqueahmedziad opened 4 years ago

atiqueahmedziad commented 4 years ago

Description of the issue Currently we have added just a few sources hard coded in search option here

We want to fetch the news sources from Sources endpoint in the API and load those sources in the option list instead of hard coded values.

vigneshwaran-chandrasekaran commented 4 years ago

Hi @atiqueahmedziad can you assign this issue to me?

atiqueahmedziad commented 4 years ago

Yeah. Sure 👍

atiqueahmedziad commented 4 years ago

To fix this issue

We want to avoid the hard-coded options in the option list since the sources will not be same all the time. It may change eventually or new sources can be added by newsapi.org. Since we are able to fetch sources from API, it is ideal that we fetch the sources and generate the options list dynamically.

I think we can fetch the sources once when user saves his API on this page. Remember that we are using cookies for storing user's API key. But we won't be able to store sources with cookies (since it is a large amount of texts). As an alternative we want to store it somewhere else at the time when user saves his API. And after that, every time the user visits the index page, the sources will be fetched from that storage and generate the options list dynamically. Remember that, we are using ejs as our templating framework.

We are using the Nodejs client library from newsapi.org for this project, check here So to conclude, we want to fetch the sources from server side once and store it somewhere in client side from where we want to fetch the sources and generate the options list.