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

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

diff --git a/src/site/pages/dashboard/admin/users.vue b/src/site/pages/dashboard/admin/users.vue
index 5195e5d..556049d 100644
--- a/src/site/pages/dashboard/admin/users.vue
+++ b/src/site/pages/dashboard/admin/users.vue
@@ -143,14 +143,7 @@ export default {
 	components: {
 		Sidebar
 	},
-	middleware: ['auth', 'admin', ({ route, store }) => {
-		try {
-			store.dispatch('admin/fetchUsers', route.params.id);
-		} catch (e) {
-			// eslint-disable-next-line no-console
-			console.error(e);
-		}
-	}],
+	middleware: ['auth', 'admin'],
 	data() {
 		return {
 			isCreateUserOpen: false,
@@ -163,6 +156,9 @@ export default {
 		users: state => state.admin.users,
 		config: state => state.config
 	}),
+	async asyncData({ app, params }) {
+		await app.store.dispatch('admin/fetchUsers', params.id);
+	},
 	methods: {
 		async changeEnabledStatus(row) {
 			if (row.enabled) {
-- 
cgit v1.2.3

