26 lines
579 B
TypeScript
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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|