Files
dlearn-front/server/api/user/registerCourse.js
T
HAM!DREZA 044c1d7685
deploy to danak / build_and_deploy (push) Has been cancelled
add payment
2025-01-05 13:15:53 +03:30

33 lines
819 B
JavaScript

export default defineEventHandler(async (event) => {
const { public: { apiBase } } = useRuntimeConfig();
const token = getCookie(event, 'token');
const body = await readBody(event);
try {
const data = await $fetch(`${apiBase}/payment`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
},
body
});
return data;
} catch (error) {
if (error.status === 406) {
return{
status: 406,
message: 'شما در این دوره شرکت کرده اید !!!'
}
}else{
return{
status: 500,
message: 'عملیات با مشکل مواجه شد، کمی بعد تلاش کنید.'
}
}
return error;
}
})