0
I am accessing an API using Node.js, which returns the following JSON to me.
I need to access the field price
, however the item PETR4:
varies according to the symbol
informed.
I can access until response.body.results
.
How can I access the next item (which in this example is PETR4
)?
{
by: 'symbol',
valid_key: true,
results: {
PETR4: {
symbol: 'PETR4',
name: 'Petróleo Brasileiro S.A. - Petrobras',
region: 'Brazil/Sao Paolo',
currency: 'BRL',
market_time: [Object],
market_cap: 255916,
price: 19.31,
change_percent: -1.63,
updated_at: '2020-09-29 20:47:36'
}
},
execution_time: 0.01,
from_cache: false
}
Sometimes the field comes
PETR4
and sometimes not, that’s it?– Shinforinpola
What can come beyond
PETR4
?– Sorack