Skip to content

Commit 05e24d7

Browse files
committed
fix todo create date error
1 parent 95c4a4b commit 05e24d7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

controllers/todoController.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@ const Todo = require('../models/Todo');
22

33
async function addTodo(req, res){
44
try {
5-
const newTodo = await Todo.create(req.body);
5+
6+
const body = req.body;
7+
const title = body.title;
8+
const description = body.description;
9+
const deadline = Date(body.deadline);
10+
11+
12+
const newTodo = await Todo.create({
13+
title,
14+
description,
15+
deadline
16+
});
617
res.status(200).json(newTodo);
718
} catch (error) {
819
console.log('cant add data: ', error.message);

0 commit comments

Comments
 (0)