How to get object array generated by axios get

Advertisements
(async() =>{
    const axios= require('axios');
    const response = await axios("https://graph.facebook.com/v13.0/110524034851999/feed?limit=3&access_token=×××××××");
    const data = response.data;
    console.log(data);
    console.log(data[0]);
})();

Above is the code I am using to get json from Facebook API I am getting an object as below

data: [
    {
      created_time: '2022-04-14T14:01:45+0000',
      message: 'How to make jw',
      id: '...'
    },
    {
      created_time: '2022-04-14T14:01:19+0000',
      message: 'Testing',
      id: '....'
    },
    {
      created_time: '2022-04-14T01:51:41+0000',
      message: 'Enriqueta',
      id: '.....'
    }
  ],

I am not able to get the data from object using data[0] which should return me first object but it’s giving me undefined error how can I get the message which is on first array of data object from the above json?

>Solution :

replace

console.log(data[0]);

with

console.log(data.data[0]);

maybe?

Leave a ReplyCancel reply