crybapp / web

Main web client for Cryb
MIT License
45 stars 14 forks source link

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

Open Soliel opened 4 years ago

Soliel commented 4 years ago

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 commented 4 years ago

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.