From 4f74c809a780c854eee2d70924b704ce4bed46e0 Mon Sep 17 00:00:00 2001 From: Lisa Liu Date: Wed, 24 Jan 2024 10:56:10 -0800 Subject: [PATCH] fixed any type value of req.body --- backend/src/controllers/program-form.ts | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/backend/src/controllers/program-form.ts b/backend/src/controllers/program-form.ts index 36952013..33719941 100644 --- a/backend/src/controllers/program-form.ts +++ b/backend/src/controllers/program-form.ts @@ -61,30 +61,12 @@ export type typeProgramForm = { export const createForm: RequestHandler = async (req, res, next) => { // extract any errors that were found by the validator const errors = validationResult(req); - const reqBody: typeProgramForm = req.body as typeProgramForm; - const { name, abbreviation, type, startDate, endDate, color } = reqBody; try { // if there are errors, then this function throws an exception validationErrorParser(errors); //errors - // const programForm = await ProgramFormModel.create({ - // name: String, - // abbreviation: String, - // type: String, - // startDate: Date, - // endDate: Date, - // color: Number, - // }); - - const programForm = await ProgramFormModel.create({ - name, - abbreviation, - type, - startDate, - endDate, - color, - }); + const programForm = await ProgramFormModel.create(req.body as typeProgramForm); // 201 means a new resource has been created successfully // the newly created task is sent back to the user