Help wanted for Third-party-apis section, new york times api

The New York Times API is a very interesting example for third party apis lecture. But there is one code puzzles me and I could not find any reference about it. Please someone gives further explanation about “.response.docs”.

const articles = json.response.docs;

Hi @Nathan_Zhang, and welcome to the community.

So, the json object passed to the displayResults() function is a JS object representation of some JSON data passed to our app from the NYTimes API. We are using dot syntax to access the docs property of the response property of the top-level json object. These responsesub-property is itself a JS object, whereas docs is an array (you can tell this because later on we use let current = articles[i];) or objects, each one representing a single news article. These values are nested inside one another.

The structure of the json object will look something like this:

{
  response : {
    docs : [
      ... ,
      ... ,
      ... ,
    ]
  }
}

Have you worked through our JS objects module? This examples a lot of these basics, plus a lot more: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects

Thanks for your detailed explanation. Really appreciate! :smile: