From a3bf693d30d3c1c1d9e4073830522554c3f1c4e8 Mon Sep 17 00:00:00 2001
From: Pitu <heyitspitu@gmail.com>
Date: Wed, 20 Jan 2021 14:09:06 +0900
Subject: chore: switch to asyncData where needed

---
 src/site/pages/dashboard/admin/statistics.vue | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

(limited to 'src/site/pages/dashboard/admin/statistics.vue')

diff --git a/src/site/pages/dashboard/admin/statistics.vue b/src/site/pages/dashboard/admin/statistics.vue
index c1e79fc..1b951fc 100644
--- a/src/site/pages/dashboard/admin/statistics.vue
+++ b/src/site/pages/dashboard/admin/statistics.vue
@@ -78,16 +78,13 @@ export default {
 		detailed,
 		generic
 	},
-	middleware: ['auth', 'admin', ({ store }) => {
-		try {
-			store.dispatch('admin/fetchStatistics');
-		} catch (e) {
-			console.error(e);
-		}
-	}],
+	middleware: ['auth', 'admin'],
 	computed: mapState({
 		stats: state => state.admin.statistics
 	}),
+	async asyncData({ app }) {
+		await app.store.dispatch('admin/fetchStatistics');
+	},
 	methods: {
 		refresh(category) {
 			try {
-- 
cgit v1.2.3

