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'
}
]
}
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'
}
]
}
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));