Im not sure if im asking the right question, but here it goes. I am hitting an API and getting an javascript object that looks like the following
x: {
id: 1,
username: 'Ryan',
picture: 151
}
Im storing this object in a myObj const. I want to access the data inside x, but the issue is each time I hit the API x changes names. The object keys inside x remain the same, but sometimes x is y, a, l, b, etc.
Right now Im trying
myObj.x
but once x is y, I would have to change it to myObj.y instead. How can I access the properties inside this dynamic object?
SOLUTION:
myObj[Object.keys(myObj)[0]]