DEV Community

Discussion on: Visual Studio Code can now convert your long chains of Promise.then()'s into async/await automagically

Collapse
 
julieneric profile image
Julien Eric

Why would it leave a then hanging off of an async call?

Collapse
 
qm3ster profile image
Mihail Malo • Edited

Which one are you talking about?

You mean the abuser would write the following?

export default {
  name: "Home",
  data: () => ({
    posts: []
  }),
  async asyncData() {
    let posts = []
    const querySnapshot = await firebase
      .firestore()
      .collection("posts")
      .orderBy("timestamp")
      .get()
    querySnapshot.forEach(doc => {
      posts.push(doc.data())
    })
    return { posts: posts }
  }
}