News-API-gh / News-API-node

Our officially supported Node client library for accessing News API.
MIT License
42 stars 3 forks source link

Missing Endpoints for Single News Item #9

Open ayoubkhan558-zz opened 4 years ago

ayoubkhan558-zz commented 4 years ago

Missing Endpoints for Single News Item, We need to fetch a single item instead of many

ian-Liaozy commented 2 years ago

Hello, I think you can try the following steps:

  1. Get the data (if you are using JavaScript, it would be fetch, other languages are similar to this)
  2. const data = data.articles.slice(0, 1); (get the first element of the articles attribute in the result) Sample code: const response = await fetch(URL); const data = await response.json(); return data.articles.slice(0, 1); It would be nice if it helps!