Basic reading of the JSON data from the API

Here's a query that displays the following results:

{
  "data": [
    {
      "id": "1107702400"
    },
    {
      "id": "1149862205",
      "likes": {
        "data": [
          {
            "name": "Penelope Test",
            "category": "Arts/entertainment/nightlife",
            "id": "411133928921438",
            "created_time": "2012-05-23T11:41:27+0000"
          },

To access the first id, you can use:

response.data[i].id

How can you retrieve the second id? (the one with "data-id-data-id" format)

There is a function that looks like this:

for(i=0;i<response.data.length;i++)
            {
                 testdiv.innerHTML +=  response.data.data[i].id + '<br/>' ;
            }

This function allows you to print the first id. What steps are needed to be able to print the second id?

Answer №1

Your example dataset

response.data[i].likes.data[0].id

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to generate a select element using the JSON data retrieved from an Ajax request

After making an AJAX call to fetch some JSON objects, I successfully retrieve them. However, I encountered an issue while trying to generate a select element from the returned JSON - it doesn't seem to create one. This is what my JavaScript looks lik ...

Exploring node.js: How to extract elements from a path

I have an array of individuals as shown below: individuals = ['personA', 'personB', 'personC']; I am looking to create a dynamic way to showcase each individual's page based on the URL. For instance, localhost:3000/indi ...

Adaptable Collection of 4 Images

I am facing a challenge in replicating eBay's 'Today' featured seller layout with 4 square images creating one box (refer to the image). I am using Bootstrap for this task, and I am finding it difficult to comprehend how to achieve this. I h ...

modification of class into hooks, receiving error message 'then' property is not found in type '(dispatch: any) => Promise<void>'

As a newcomer to React hooks, I have been converting code from class components to hooks. However, I am encountering an error message when trying to use 'then' in hooks that says 'Property 'then' does not exist on type '(dispa ...

Best practices for using parent and child methods in Vue applications

I'm exploring the most effective approach to creating a modal component that incorporates hide and show methods accessible from both the parent and the component itself. One option is to store the status on the child. Utilize ref on the child compo ...

What is the best way to find the common elements in two datasets using Nuxt?

I attempted to retrieve data from an API using parameters that are passed through an argument in a v-for loop. In the findUser function, I am able to successfully log the desired data. However, I am unable to retrieve it at the end of the findUser function ...

Enter data into a specific text field (similar to entering data in Selenium RC) using Selenium WebDriver

Looking for a solution: I need to input text into a focused text area that does not have a static xpath. To achieve this, I am currently using Actions actions = new Actions(driver); actions.sendKeys(textarea).perform(); However, this method is pasting th ...

retrieve the child element's value of the directive

Having trouble with this directive: app.directive("myarticle",function($timeout){ return { restrict: "E", replace: true, templateUrl: "templates/article.html", link: function(scope, element, attrs) { element.getVal() } , ...

Creating dynamic bar chart visuals using Morris.js with JSON responses

Utilizing the morris.js library, I am extracting and plotting bar charts from data retrieved through a webservice. Issue: The format of my webservice URL is as follows: http://localhost:9999/hellowebservice/search?select=* I populate the select query ...

Problems with Key Presses in Form Verification

Yesterday evening, our supervisor called me to report an issue with our app. He mentioned that when he tried to log in using a dummy password, the validation was successful. It seems that clicking on the mouse to authenticate the password was working corr ...

The IF Else statement encountered some issues within the setInterval() function while trying to implement a countdown timer

Even though I added an if-else statement inside the setInterval() function to clear the interval when my time variable reaches 0, the setInterval() continues running with a negative time value. Can you please identify the issue and suggest a solution? Be ...

Choosing specific content from a different div in JavaScript based on the line number

I have a question regarding two div elements, div1 and div2. I am trying to develop a function where in div2, I can specify the line number of div1 and display the relevant content from that specific line. Currently, I have created a function that successf ...

Encountered a MongoNetworkError while attempting to establish a connection with the server at localhost:27017. The initial connection failed due to an ECONNREFUSED error at 127.0.0.1:

Encountered a MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017 If I reinstall MongoDB, the code works fine. However, I am looking for a permanent solution. [error:MongoNetworkE ...

I am hoping to extract the URL information that includes a hash mark # and then implement it within a PHP framework

I am looking to extract a URL with a hash and then send it to PHP for processing I understand how to retrieve the # value using jQuery <?php $url = $_GET['url']; // this is a dynamic URL string e.g. https://example.com/myfile/#url=someDy ...

What steps can I take to maintain persistent authentication in AngularJS?

As a newcomer to angular js, I am currently working on a demo application that features a login screen as the initial view. Upon successful login, other views are loaded along with a navigation bar included using ng-include in the index.html page. The navi ...

Generating HTML tags on-the-fly in Angular 2

Is it possible to generate an HTML tag dynamically within a component's template? For example: template:`<{{custom_tag}} [info]="info"></{{custom_tag}}>` ... this.custom_tag="example"; this.info={}; The resulting HTML would look like th ...

The URL in a request is altered prior to execution

I am encountering an issue with my NodeJS application where it automatically appends my domain to the URL set in my http request. How can I prevent this from happening? I have tried to search for similar problems but have not found any relevant solutions. ...

Stateless components in ReactJS can accept parameters as props

When it comes to ReactJS stateless components, what is the best practice for defining parameters? Should you use props or specify all prop names individually? Option 1: const Checkbox = props => {} Option 2: const Checkbox = ({name, value}) => {} ...

Using arrow functions in Typescript e6 allows for the utilization of Array.groupBy

I'm attempting to transform a method into a generic method for use with arrow functions in JavaScript, but I'm struggling to determine the correct way to do so. groupBy: <Map>(predicate: (item: T) => Map[]) => Map[]; Array.prototype ...

Utilizing Jackson JsonSerializer with the @ResponseBody annotation in Spring for an enum interface

Similar inquiries Spring @ResponseBody Jackson JsonSerializer with JodaTime Usage of @JsonSerialize and JsonSerializer The Issue at Hand In my code, there is an enum defined as follows: @JsonSerialize(using = JSONI18NSerializer.class) public enum Stat ...