Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save navarroaxel/9a441f776824a58fed3a80160308ee54 to your computer and use it in GitHub Desktop.
Save navarroaxel/9a441f776824a58fed3a80160308ee54 to your computer and use it in GitHub Desktop.
_.reduce(req.body.labels,
(promise, requestLabel) => promise.then(
() => {
var label = new model.Label(requestLabel);
label.branch = DISTRIBUTION_BRANCH_ID;
return labelsService.createLabel(label);
}
),
Promise.resolve()
).then(
() => res.sendStatus(200),
err => next(Error.create('An error occurred trying to save the labels.', {
labels: req.body.labels
}, err))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment