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