nuxt-start/stores/auth.ts
2025-01-01 23:06:17 +01:00

26 lines
579 B
TypeScript

import { defineStore } from 'pinia'
export const useAuthStore = defineStore({
id: 'AuthStore',
state: () => ({ user: null,rentals:null,rent:{} }),
actions: {
async getData() {
const token = useCookie('_auth')
if (token.value) {
const { data } = await useFetch('https://olcsoberauto.hu/rest/me',
{
headers: {
'auth-key': token.value
}
}
)
if(data.value?.user){
this.user = data.value.user
this.rentals = data.value.rentals
}
}
}
}
})