update
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { public: { apiBase } } = useRuntimeConfig();
|
||||
const token = getCookie(event, 'token');
|
||||
const body = await readBody(event);
|
||||
console.log(body);
|
||||
try {
|
||||
const data = await $fetch(`${apiBase}/user/registerCourse`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
body
|
||||
});
|
||||
console.log(data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.log('errors',error.data);
|
||||
if (error.status === 406) {
|
||||
return{
|
||||
status: 406,
|
||||
message: 'شما در این دوره شرکت کرده اید !!!'
|
||||
}
|
||||
}else{
|
||||
return{
|
||||
status: 500,
|
||||
message: 'عملیات با مشکل مواجه شد، کمی بعد تلاش کنید.'
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user