27 lines
727 B
JavaScript
27 lines
727 B
JavaScript
export default defineEventHandler(async (event) => {
|
|
|
|
const { public: { apiBase } } = useRuntimeConfig();
|
|
const token = getCookie(event, 'token');
|
|
|
|
try {
|
|
const data = await $fetch(`${apiBase}/ticket`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Authorization': `Bearer ${token}`
|
|
}
|
|
});
|
|
return data;
|
|
} catch (error) {
|
|
// if (error.statusCode == 401) {
|
|
// setCookie(event, 'token', '', {
|
|
// httpOnly: true,
|
|
// secure: true,
|
|
// maxAge: new Date(0),
|
|
// path: '/'
|
|
// })
|
|
// }
|
|
return error;
|
|
}
|
|
|
|
}) |