I am currently facing an issue with my code that is returning all news related to a company. However, I only want the first 15 elements. Is there a way to achieve this? The following code snippet retrieves all news for a company using the google-news-json npm package.
export default async function handler(req, res) {
try {
let news = await googleNewsAPI.getNews(googleNewsAPI.SEARCH, req.body.companyName, 'en-US')
res.status(200).json(news)
} catch (err) {
res.status(500).json({ error: 'Failed to fetch news' })
}
}