update
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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}/courseHeadlineComment/create`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
body
|
||||
});
|
||||
console.log(data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
})
|
||||
@@ -3,8 +3,6 @@ export default defineEventHandler(async (event) => {
|
||||
const token = getCookie(event, 'token');
|
||||
const body = await readBody(event);
|
||||
const query = getQuery(event);
|
||||
console.log('c s',body);
|
||||
console.log(query);
|
||||
|
||||
try {
|
||||
const data = await $fetch(`${apiBase}/course/${query.id}/comment`, {
|
||||
@@ -15,7 +13,7 @@ export default defineEventHandler(async (event) => {
|
||||
},
|
||||
body
|
||||
});
|
||||
console.log('ser com', data);
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { public: { apiBase } } = useRuntimeConfig();
|
||||
|
||||
const query = getQuery(event);
|
||||
|
||||
|
||||
// let page = query.hasOwnProperty('page') ? `page=${query.page}` : '';
|
||||
// // let sortBy = query.hasOwnProperty('sortBy') ? `price=${query.price}` : '';
|
||||
// let price = query.hasOwnProperty('price') ? `price=${query.price}` : '';
|
||||
try {
|
||||
const courseHeadline = await $fetch(`${apiBase}/courseHeadline?courseId=${query.id}`, {
|
||||
const data = await $fetch(`${apiBase}/courseHeadline?courseId=${query.id}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'content-type': 'application/json'
|
||||
}
|
||||
});
|
||||
console.log(courseHeadline);
|
||||
return courseHeadline;
|
||||
return data;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -11,22 +11,25 @@ export default defineEventHandler(async (event) => {
|
||||
})
|
||||
|
||||
|
||||
let formDat = new FormData();
|
||||
formDat.append('file', fs.createReadStream(files.file[0].filepath));
|
||||
var formDat = new FormData();
|
||||
formDat.append('directoryName', fields.directoryName[0]);
|
||||
formDat.append('file', fs.createReadStream(files.file[0].filepath));
|
||||
// console.log('path',files.file[0].filepath);
|
||||
// console.log('text',fields.directoryName[0]);
|
||||
try {
|
||||
const data = await $fetch(`${apiBase}/uploader`, {
|
||||
method: 'POST',
|
||||
body: formDat,
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
//'Content-Type': 'multipart/form-data',
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
});
|
||||
console.log('uploader data', data);
|
||||
console.log('uplodar',data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.log('error', error);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ 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/add`, {
|
||||
method: 'POST',
|
||||
|
||||
@@ -9,7 +9,7 @@ export default defineEventHandler(async (event) => {
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
});
|
||||
console.log('server', payments);
|
||||
|
||||
return payments;
|
||||
} catch (error) {
|
||||
|
||||
|
||||
@@ -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