Created
July 11, 2019 19:49
-
-
Save Jmzp/bda5aa654a7b1aae40ba2cfe98f5e544 to your computer and use it in GitHub Desktop.
Revisions
-
Jmzp created this gist
Jul 11, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ router.get('/task/:id', async (ctx) => { await Task.findOne({ where: { id: ctx.params.id } }) .then(tasks => { if (tasks === null){ Object.assign(ctx, { status: 404, body: { errors: [{ msg: 'Task does not exist' }] } }); } else { ctx.body = tasks; } }) .catch(() => { Object.assign(ctx, { status: 500, body: { errors: [{ msg: err }] } }); }) });