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/user/_id.vue | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

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

diff --git a/src/site/pages/dashboard/admin/user/_id.vue b/src/site/pages/dashboard/admin/user/_id.vue
index 6079bab..7e0b182 100644
--- a/src/site/pages/dashboard/admin/user/_id.vue
+++ b/src/site/pages/dashboard/admin/user/_id.vue
@@ -95,14 +95,7 @@ export default {
 		Sidebar,
 		Grid
 	},
-	middleware: ['auth', 'admin', ({ route, store }) => {
-		try {
-			store.dispatch('admin/fetchUser', { id: route.params.id });
-		} catch (e) {
-			// eslint-disable-next-line no-console
-			console.error(e);
-		}
-	}],
+	middleware: ['auth', 'admin'],
 	data() {
 		return {
 			options: {},
@@ -121,6 +114,9 @@ export default {
 	watch: {
 		current: 'fetchPaginate'
 	},
+	async asyncData({ app, params }) {
+		await app.store.dispatch('admin/fetchUser', { id: params.id });
+	},
 	methods: {
 		...mapActions({
 			fetch: 'admin/fetchUser'
-- 
cgit v1.2.3

