mirror of
https://github.com/bitinflow/nuxt-oauth.git
synced 2026-03-13 13:45:59 +00:00
30 lines
480 B
Vue
30 lines
480 B
Vue
<script setup lang="ts">
|
|
import {useAuth, useNuxtApp} from "#imports";
|
|
|
|
const {user, signOut} = await useAuth();
|
|
|
|
definePageMeta({
|
|
middleware: ["auth"]
|
|
})
|
|
|
|
const { $api } = useNuxtApp()
|
|
|
|
$api.get('users/@me')
|
|
.then((response: any) => {
|
|
console.log(response.data)
|
|
})
|
|
.catch((error: any) => {
|
|
console.log(error)
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div v-if="user">
|
|
Hello {{ user.name }}
|
|
|
|
<button @click="signOut">
|
|
Sign Out
|
|
</button>
|
|
</div>
|
|
</template>
|