I am trying to retrieve the data from the last month of an API, but I want to avoid hard-coding the date like this:
const data = [data.data['Monthly Time Series']['2021-11-30']]
. I need a way to dynamically access the 2nd object without specifying the date, so it always displays the actual data from the past month. Any assistance would be greatly appreciated.
This is a snippet of how the JSON structure appears:
{
"Meta Data": {
"1. Information": "Monthly Prices (open, high, low, close) and Volumes",
"2. Symbol": "IBM",
"3. Last Refreshed": "2021-12-08",
"4. Time Zone": "US/Eastern"
},
"Monthly Time Series": {
"2021-12-08": {
"1. open": "118.2500",
"2. high": "123.3800",
"3. low": "116.5600",
"4. close": "123.0200",
"5. volume": "33320654"
},
"2021-11-30": {
"1. open": "125.0500",
"2. high": "127.2900",
"3. low": "114.5600",
"4. close": "117.1000",
"5. volume": "119252012"
},