From 64c14db18366af6f053fd4c5fad3492c02ba4143 Mon Sep 17 00:00:00 2001 From: Spacelord Date: Tue, 16 May 2023 17:58:53 +0200 Subject: [PATCH] Add created id to response of storageUnit api --- src/routes/api/v1/storageUnits.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/routes/api/v1/storageUnits.ts b/src/routes/api/v1/storageUnits.ts index aecd451..0c62c1a 100644 --- a/src/routes/api/v1/storageUnits.ts +++ b/src/routes/api/v1/storageUnits.ts @@ -78,10 +78,13 @@ function post(req: Request, res: Response) { country: req.body.country } } + }, + 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. @@ -110,10 +113,13 @@ function post(req: Request, res: Response) { id: parseInt(req.body.locationId) } } + }, + 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.