1

So I'm calling an API with node-fetch and I want to get the imageUrl part of the JSON how would I get there with json.data.?

{
 data: [
   {
     targetId: 8325785,
     state: 'Completed',
     imageUrl: 'imageUrl'
   }
  ]
}
Sam
  • 15
  • 6

1 Answers1

0

you can get by json.data[0].imageUrl array first object and for all imageUrl you need foreach loop

let obj ={
 data: [
   {
     targetId: 8325785,
     state: 'Completed',
     imageUrl: 'imageUrl'
   }
  ]
}

if(obj.data[0] !=undefined)
{
  console.log(obj.data[0].imageUrl);
}

obj.data.forEach(element => console.log(element.imageUrl));
Mohammad Ali Rony
  • 4,695
  • 3
  • 19
  • 33