#Doesn't show error page if called from inside an async function.

12 messages · Page 1 of 1 (latest)

true grotto
#
methods:{
            async getPosts(time = 0) {
                let got = await fetch('/getPosts', { method: 'POST', body: JSON.stringify({ section: '*', modifiedAfter: time }) })
                    .then(r => r.json())
                    .catch(fetchError)

                if (got.success) {
                    this.posts.push(...got.docs)
                    if (got.docs.length < got.limit) this.reachedEnd = true
                    this.sections = got.sections
                    // return
                }

                throw createError({ fatal: true })
            }
}
#

Here I'm manually triggering this error.

cursive storm
#

Where are you calling that function?

true grotto
#
        mounted() {
            this.getPosts()
        }
#

Throws error in the console though

cursive storm
#

If you want to show an error page at that point you can use showError.

true grotto
#

Thanks. showError worked. But why createError doesn't work?

cursive storm
#

It's being called in mounted, so it's not being caught and handled anywhere

true grotto
#

showError also logs error in the console. Is there any way to get rid of that?

#

Will that error cause any problem? or just console.error() that won't cause problems?

#

BTW thanks lot for spending your precious time helping me.