function getData() {
// fetch("data.json")
fetch(
"https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=MSFT&interval=5min&apikey=demo"
)
.then(response => response.json())
.then(json => console.log(json["Time Series (5min)"]));
}
$(function() {
$("#container").highcharts({
series: [
{
data: [
29.9,
71.5,
106.4,
129.2,
144.0,
176.0,
135.6,
148.5,
216.4,
194.1,
95.6,
54.4
]
}
]
});
// the button action
$("#button").click(function() {
var chart = $("#container").highcharts();
chart.series[0].setData(
[129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
false
);
});
});
Hello everybody,
I have a problem where I need help please.I do an API call with the fetch API and want to display the resulting array in a chart. How can I do this? I want to pass the result to the array in the “setData” method. The problem is I have no idea how to store the results of the API call in a variable (it seems to be because of the async character). Can you help me there?