I have an object "data" from 'https://randomuser.me/api/' which I'm using in my project.
{
"results": [
{
"gender": "female",
"name": {
"title": "miss",
"first": "mia",
"last": "sutton"
}
}
]
}
I destructured results from the data object as follows;
const {results} = data;
How do I destructure the results variable I created, and obtain the first item from it I want the de-structured array item to be declared as profile. This represents the profile data for the user gotten from the API call that I want to display in my app.
const {results: [{name: {title, first, last}}]} = data;This will completly destructure the first item on your list.myArray. So when I logmyArray, I should get; ` { "gender": "female", "name": { "title": "miss", "first": "mia", "last": "sutton" }`const {results: [firstPerson]} = data;firstPersonrepresent the array item's new variable name?