refactoring on back end

This commit is contained in:
Mikayla Dobson
2022-12-17 13:30:55 -06:00
parent be375aad8f
commit 9a43f58ee3
15 changed files with 117 additions and 90 deletions

View File

@@ -8,8 +8,8 @@ export const courseRouter = (app: Express) => {
router.get('/', async (req, res, next) => {
try {
const result = await CourseInstance.getAll();
res.status(200).send(result);
const { code, data } = await CourseInstance.getAll();
res.status(code).send(data);
} catch(e) {
next(e);
}
@@ -19,8 +19,8 @@ export const courseRouter = (app: Express) => {
const { id } = req.params;
try {
const result = await CourseInstance.getOne(id);
res.status(200).send(result);
const { code, data } = await CourseInstance.getOne(id);
res.status(code).send(data);
} catch(e) {
next(e);
}
@@ -31,7 +31,7 @@ export const courseRouter = (app: Express) => {
try {
const result = await CourseInstance.post(data);
res.status(201).send(result);
res.status(result.code).send(result.data);
} catch(e) {
next(e);
}