avoid errors when trying to call createTasks with no tasks (#10170)

This commit is contained in:
Matteo Pagliazzi
2018-03-23 17:15:50 +01:00
committed by GitHub
parent 99852fcd89
commit fa17ab7c17

View File

@@ -77,6 +77,9 @@ export async function createTasks (req, res, options = {}) {
let toSave = Array.isArray(req.body) ? req.body : [req.body];
// Return if no tasks are passed, avoids errors with mongo $push being empty
if (toSave.length === 0) return [];
let taskOrderToAdd = {};
toSave = toSave.map(taskData => {