const plots = [];
Object.values(response.data).forEach(d => {
if (d.hasOwnProperty('plots')) {
plots .push(...d.plots);
}
});
Dec 12, 2022
2
Level 3
Filtering data returned by axios after a specific array
Hi Fellows.
I'm trying to filter my returned axios data, which looks like this:
{
"data": {
"9491931395853: {
"labels": [
"2022-11-07 00:00:00",
"2022-11-09 00:00:00",
"2022-11-10 00:00:00",
"2022-11-12 00:00:00",
],
"plots": [
34,
0,
30,
66
]
},
I need to get access to the plots in this one, and normally it should work by iterating over it, but it doesn't. I do not know what i'm doing wrong. I need those plots to implement them in a standard line chart (eCharts in an Vue Component).
the "9491931395853" is variable. Stands for a ProductID which comes with the fetch from the API. Thought it should work with Array.prototype.filter() like
const plots = Object.values(response.data).filter(data => data.hasOwnProperty("plots"));
Could you guys help me out here?
Please or to participate in this conversation.