Getting Properties from API call

Getting Properties from API call
0.0 0

#1

Hi!

I am currently working on the WikiViewer App. I got everything working, and also my API call returns me 10 random pages that I like to append to my page. But I can’t access the properties (title, extract, pageid). They return as undefined although the complete array I got is filled with this information.


#2

Hi,

As far as I can see, the result you get from the API contains just 3 arrays. Where do you see the properties you want to access?


#3

If you go through query.pages then there are 10 pages and in those Objects are these properties


#4

Okay, so what I am missing?

If I comment out the console.log(data) and search for “test”, I get the following:

In your case, you can access the first title like this: query.pages["13375713"].title. If you use Object.keys() on the query.pages you should be able to get an array of all those numbers.


#5

Thank you! Object.keys(…) was what I was looking for :slight_smile: