i’m trying to get the value of a Object in my array. Basically when i’m doing
JavaScript
x
3
1
var firsts = response.data;
2
console.log(firsts)
3
I have something like that
JavaScript
1
4
1
{
2
"EUR_BND": 1.603476
3
}
4
But the name of the object is changing every time, so i can’t do
JavaScript
1
2
1
response.data.EUR_BND
2
I wondered if there was a way to directly get the value of the only object, without having to go through its name.
Advertisement
Answer
You can use the object.values
JavaScript
1
2
1
Object.values(response.data)
2
Which would return an array of the values in the object
Object.values(response.data)[0]
would return the value if you have one