Open Thenewchicken55 opened 3 days ago
The endpoint is something along the lines of this: https://newsapi.org/v2/{{type}}?q=&from=&sortBy=&apiKey=
type: can be "top-headlines" or "everything", i think there are more?????? ill have to check q: refers to content in the title (ie 'apple' would return all articles with apple in the title) from: refers to a date, 2024-11-20 sortBy: self explanatory, popularity and date are two options apiKey: the api key
i think the mongoose type should look something like:
const newsApiRequestSchema = new mongoose.Schema({ type: { type: String, required: true, enum: ['top-headlines', 'everything'] }, q: { type: String, }, from: { type: Date, }, sortBy: { type: String, enum: ['popularity', 'date'], // there are more options we can add later }, });
Sounds good. Feel free to make any commits u want. Just to confirm, So are we querying news and storing it in db? I think that works well.
yep
oops, i just realized you were referring to the news article type, not the request
This is what i found as a suggestion on newsapi all of these values should be in the payload we get back from the call
type NewsArticle = { source: { id: string | null; name: string; }; author: string | null; title: string; description: string | null; url: string; urlToImage: string | null; publishedAt: string; content: string | null; };
For now, the code can read an array of articles and display it. We need to somehow query the database (or dataset) instead and get data. Note, the database is not implemented yet I don't think.