Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change asyncData Functions to promise for more concise syntax. #104

Open
Soliel opened this issue Jan 21, 2020 · 1 comment
Open

Change asyncData Functions to promise for more concise syntax. #104

Soliel opened this issue Jan 21, 2020 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Soliel
Copy link
Contributor

Soliel commented Jan 21, 2020

I think this function is better as a promise.

        asyncData = (context) => new Promise((resolve, reject) => {
            context.$axios.$get('auth/discord/redirect')
                .then(result => resolve(result))
                .catch(reason => reject(reason))
        })

Originally posted by @Soliel in https://github.com/crybapp/web/diffs

@Soliel
Copy link
Contributor Author

Soliel commented Jan 21, 2020

asyncData functions are very large despite not doing all that much and are better expressed as a promise.

The expression as a promise leads to a much more concise syntax as shown above.

Not a very important change but it would be a nice one.

According to @JeDaYoshi there were some issues with handling it as a promise. This page may or may not shed some light on the issue: https://nuxtjs.org/guide/async-data/

This issue is to resolve the inability to use promises for async data and adopt the syntax.

@JeDaYoshi JeDaYoshi added enhancement New feature or request good first issue Good for newcomers labels Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants