DEV Community

loading...

Discussion on: Train wagons 🚃.🚃.🚃

Collapse
miketalbot profile image
Mike Talbot

You can also write the second approach without promises (because there is nothing async after the first element) and it's a bit faster :)

promise.then(({data})=>{
      const {users} = data
      const [firstUser] = users
      const {name="mike"} = firstUser
})

or if you just care about firstUser:

promise.then(({data: {users: [firstUser]}})=>{
     const {name} = firstUser
})
Collapse
codingunicorn profile image
Forem Open with the Forem app