Skip to content

Commit

Permalink
fix: user fetching problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Intevel committed Mar 23, 2022
1 parent 6fb9436 commit 47b7027
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/runtime/composables/useDirectusAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export const useDirectusAuth = () => {
const fetchUser = async (): Promise<Ref<DirectusUser>> => {
if (token.value && !user.value) {
try {
user.value = await directus("/users/me");
var res = await directus("/users/me");
setUser(res.data);
} catch (e) {
setToken(null);
}
Expand Down
6 changes: 4 additions & 2 deletions src/runtime/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { defineNuxtPlugin } from "#app";

export default defineNuxtPlugin((nuxtApp) => {
console.log("Directus");
export default defineNuxtPlugin(async (nuxtApp) => {
const { fetchUser } = useDirectusAuth();

await fetchUser();
});

0 comments on commit 47b7027

Please sign in to comment.