-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.vue
More file actions
33 lines (28 loc) · 813 Bytes
/
app.vue
File metadata and controls
33 lines (28 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<script setup lang="ts">
import { useAuthStore } from '~/store/useAuthStore'
const { register, login, getMe } = useAuthStore()
await useAsyncData('users', () => getMe())
const user = useUser()
const handleRegister = async () => {
try {
await register({ name: 'cem', surname: 'sönmez', email: 'cem@cem.com', password: 'Cem123..' })
} catch (err) {
console.log('err', err)
}
}
const handleLogin = async () => {
try {
await login({ email: 'cem@cem.com', password: 'Cem123..' })
await getMe()
} catch (err) {
console.log('err', err)
}
}
</script>
<template>
<div>
<button @click="handleRegister">Register</button>
<button @click="handleLogin">Login</button>
<span>{{ user && user.email }}</span>
</div>
</template>