complete progress section

This commit is contained in:
HAM!DREZA
2024-07-01 23:09:43 +03:30
parent 87e16dc016
commit a8e723ddf0
28 changed files with 333 additions and 103 deletions
+20
View File
@@ -0,0 +1,20 @@
export default defineEventHandler(async (event) => {
const { public: { apiBase } } = useRuntimeConfig();
const token = getCookie(event, 'token');
const query = getQuery(event);
try {
const data = await $fetch(`${apiBase}/uploader/file?fileName=${query.fileName}`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
return data;
} catch (error) {
return error;
}
});
+2 -2
View File
@@ -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}/courseHeadlineComment/create`, {
method: 'POST',
@@ -12,7 +12,7 @@ console.log(body);
},
body
});
console.log(data);
return data;
} catch (error) {
+1 -1
View File
@@ -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}/courseHeadlineComment/reply`, {
method: 'POST',
+2 -2
View File
@@ -13,10 +13,10 @@ export default defineEventHandler(async (event) => {
},
body
});
console.log(data);
return data;
} catch (error) {
console.log(error);
return error;
}
+24
View File
@@ -0,0 +1,24 @@
export default defineEventHandler(async (event) => {
const { public: { apiBase } } = useRuntimeConfig();
const query = getQuery(event);
let category = query.hasOwnProperty('category') ? `categoryId=${query.category}` : '';
let page = query.hasOwnProperty('page') ? `page=${query.page}` : '';
// let sortBy = query.hasOwnProperty('sortBy') ? `price=${query.price}` : '';
let price = query.hasOwnProperty('price') ? `price=${query.price}` : '';
let name = query.hasOwnProperty('name') ? `name=${query.name}` : '';
try {
const data = await $fetch(`${apiBase}/course?${category}&${page}&pageSize=2&${price}&${name}`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'content-type': 'application/json'
}
});
return data;
} catch (error) {
return error;
}
});
+22
View File
@@ -0,0 +1,22 @@
export default defineEventHandler(async (event) => {
const { public: { apiBase } } = useRuntimeConfig();
const body = await readBody(event);
const token = getCookie(event, 'token');
try {
const data = await $fetch(`${apiBase}/course/${body.id}?userId=${body.userId}`, {
headers: {
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
},
});
return data;
} catch (error) {
return error;
}
})
+23
View File
@@ -0,0 +1,23 @@
export default defineEventHandler(async (event) => {
const { public: { apiBase } } = useRuntimeConfig();
const body = await readBody(event);
const token = getCookie(event, 'token');
try {
const data = await $fetch(`${apiBase}/courseHeadline/complete/${body.id}`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
},
});
return data;
} catch (error) {
return error;
}
})
+3 -3
View File
@@ -7,7 +7,7 @@ export default defineEventHandler(async (event) => {
const formData = await readFormData(event);
console.log(formData);
try {
@@ -19,10 +19,10 @@ export default defineEventHandler(async (event) => {
'Authorization': `Bearer ${token}`
},
});
console.log('uplodar', data);
return data;
} catch (error) {
console.log(error.data);
return error;
}
+3 -3
View File
@@ -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/registerCourse`, {
method: 'POST',
@@ -12,10 +12,10 @@ export default defineEventHandler(async (event) => {
},
body
});
console.log(data);
return data;
} catch (error) {
console.log('errors',error.data);
if (error.status === 406) {
return{
status: 406,