Considering this API randomuser, how do I destructure the API to obtain the results property?
            Asked
            
        
        
            Active
            
        
            Viewed 850 times
        
    -9
            
            
        - 
                    1Which properties exactly are you trying to access via destructuring? – Robert Koritnik Mar 13 '19 at 12:25
- 
                    @RobertKoritnik The 'results' property – OdunayoO Mar 13 '19 at 12:27
- 
                    1Possible duplicate of [What is destructuring assignment and its uses?](https://stackoverflow.com/questions/54605286/what-is-destructuring-assignment-and-its-uses) – Code Maniac Mar 13 '19 at 12:27
2 Answers
1
            
            
        {results : [{gender etc.}]} then you will only get the properties enumerated
 
    
    
        Michael
        
- 4,538
- 5
- 31
- 58
0
            
            
        Here's how you would destruct the results prop from that endpoint:
(async () => {
  const data = await fetch('https://randomuser.me/api/')
  const { results } = await data.json()
  console.log(results) // returns `results` array from object
})() 
    
    
        noetix
        
- 4,773
- 3
- 26
- 47
