fixed task api route
This commit is contained in:
parent
7b876caf36
commit
3c09d935e1
13
api/tasks.js
13
api/tasks.js
@ -4,14 +4,15 @@ module.exports = router
|
|||||||
|
|
||||||
/* CREATE */
|
/* CREATE */
|
||||||
router.post('/', async (req, res, next) => {
|
router.post('/', async (req, res, next) => {
|
||||||
const project = await Project.findOne({
|
|
||||||
where: { name: req.body.projectName },
|
|
||||||
})
|
|
||||||
await console.log('Project\n', project.id)
|
|
||||||
try {
|
try {
|
||||||
const task = await Task.create(req.body)
|
const task = await Task.create(req.body)
|
||||||
await task.setProject(project.id)
|
|
||||||
await console.log('task.projectId:', task.projectId)
|
if (req.body.projectId) {
|
||||||
|
const project = await Project.findOne({
|
||||||
|
where: { id: req.body.projectId },
|
||||||
|
})
|
||||||
|
await task.setProject(project.id)
|
||||||
|
}
|
||||||
res.json(task)
|
res.json(task)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
next(err)
|
next(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user