31st May 2022, 5:12 PM
Davinder Kumar
Davinder Kumar - avatar
4 Antworten
+ 1
According to newsapi's get started page / javascript , https://newsapi.org/docs/get-started, an object is returned from response.json(). And this is the reason you are seeing an error message, you are trying to iterate over an object. To access the articles/array of the object, try data.articles.forEach(....)
31st May 2022, 9:54 PM
ODLNT
ODLNT - avatar
0
Check the data type of data Is it an array? And also I will advice you create a function outside and pass data as a parameter instead of all in there
31st May 2022, 5:36 PM
Faisal Issaka
Faisal Issaka - avatar
0
all i have done as you said but it shows now undefined data on user interface i try to solve this issue now.
31st May 2022, 6:46 PM
Davinder Kumar
Davinder Kumar - avatar
0
Is the data response an array?
31st May 2022, 8:19 PM
Faisal Issaka
Faisal Issaka - avatar