From 533bc1744d55d5009dfa2860c410ce8052262aa4 Mon Sep 17 00:00:00 2001 From: Spacelord Date: Tue, 16 May 2023 18:01:10 +0200 Subject: [PATCH] Add created id to response of category api --- src/routes/api/v1/categories.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/routes/api/v1/categories.ts b/src/routes/api/v1/categories.ts index 2fb187a..c16131a 100644 --- a/src/routes/api/v1/categories.ts +++ b/src/routes/api/v1/categories.ts @@ -42,10 +42,13 @@ function post(req: Request, res: Response) { data: { name: req.body.name, description: req.body.description + }, + select: { + id: true } }) - .then(() => { - res.status(201).json({ status: 'created' }); + .then((data) => { + res.status(201).json({ status: 'created', id: data.id }); }) .catch((err) => { // Check if an entry already exists.