0

I am using wikipedia api to get some data from them I am getting data response in this manner.

{
    "batchcomplete": "",
    "continue": {
        "accontinue": "WYSIWYG_extensions/da",
        "continue": "-||"
    },
    "query": {
        "allcategories": [
            {
                "size": 1,
                "pages": 1,
                "files": 0,
                "subcats": 0,
                "*": "WikibaseRepoEntityTypes extensions/ar"
            },
            {
                "size": 5,
                "pages": 5,
                "files": 0,
                "subcats": 0,
                "*": "WikibaseRepoEntityTypes extensions"
            },

i want to get the data from "*" key from the objects that I am getting back but i am not able to my IDE sees it as a problem. What should I do?This the way my IDE is seeing it

2 Answers2

1

You can try console.log(resp.query.allcategories[0]['*']);

This is bracket notation

Sudhanshu Kumar
  • 1,926
  • 1
  • 9
  • 21
1

Try to access it like this

console.log(resp.query.allcategories[0]['*']);

It should work
please refer this for more info
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors#bracket_notation

mss
  • 1,423
  • 2
  • 9
  • 18