Completion of APIs except for user progress
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/reply`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
body
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
})
|
||||
@@ -13,10 +13,10 @@ export default defineEventHandler(async (event) => {
|
||||
},
|
||||
body
|
||||
});
|
||||
|
||||
console.log(data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
|
||||
console.log(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { public: { apiBase } } = useRuntimeConfig();
|
||||
try {
|
||||
const data = await $fetch(`${apiBase}/common/settings`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'content-type': 'application/json'
|
||||
}
|
||||
});
|
||||
return data;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
});
|
||||
+26
-23
@@ -4,32 +4,35 @@ import fs from 'fs';
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { public: { apiBase } } = useRuntimeConfig();
|
||||
const token = getCookie(event, 'token');
|
||||
// const body = await readBody(event);
|
||||
// console.log('body', body);
|
||||
const { fields, files } = await readFiles(event, {
|
||||
includeFields: true,
|
||||
})
|
||||
|
||||
|
||||
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]);
|
||||
// const { fields, files } = await readFiles(event, {
|
||||
// includeFields: true,
|
||||
// })
|
||||
const formData = await readFormData(event);
|
||||
console.log(formData);
|
||||
// const form = new FormData()
|
||||
// form.append('directoryName', fields.directoryName[0])
|
||||
// form.append('file', fs.createReadStream(files.file[0].filepath))
|
||||
// console.log('files', files);
|
||||
// console.log('file[0]', files.file[0]);
|
||||
// console.log('form', form);
|
||||
// for (var pair of form.entries()) {
|
||||
// console.log('pairs :', pair[0] + ', ' + pair[1]);
|
||||
// }
|
||||
|
||||
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('uplodar',data);
|
||||
return data;
|
||||
const data = await $fetch(`${apiBase}/uploader`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
});
|
||||
console.log('uplodar', data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
|
||||
console.log(error.data);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ export default defineEventHandler(async (event) => {
|
||||
const data = await $fetch(`${apiBase}/user/update`, {
|
||||
method: 'PUT',
|
||||
body: {
|
||||
avatarMediaId: "",
|
||||
avatarMedia: body.avatarMedia,
|
||||
name: body.name,
|
||||
lastName: "",
|
||||
userName: "",
|
||||
|
||||
Reference in New Issue
Block a user