Cool, and there are definitely valid use cases for this, but I am scared the people who are too enthusiastic about async/await will abuse this and the amount of PRs that change
async
await
const getPosts = () => firebase .firestore() .collection('posts') .orderBy('timestamp') .get() .then(querySnapshot => querySnapshot.map(doc => doc.data())) export default { name: 'Home', data: () => ({ posts: [] }), async asyncData() { return { posts: await getPosts() } } }
into
export default { name: "Home", data: () => ({ posts: [] }), async asyncData() { let posts = [] await firebase .firestore() .collection("posts") .orderBy("timestamp") .get() .then(querySnapshot => { querySnapshot.forEach(doc => { posts.push(doc.data()) }) }) return { posts: posts } } }
Why would it leave a then hanging off of an async call?
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 } } }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Cool, and there are definitely valid use cases for this, but I am scared the people who are too enthusiastic about
async
/await
will abuse this and the amount of PRs that changeinto
Why would it leave a then hanging off of an async call?
Which one are you talking about?
You mean the abuser would write the following?