fix(controllers): update model slug in updateModel function

The model slug has been updated to use `req.params["modelSlug"]` instead of `body.slug_name` in the `updateModel` function, ensuring the correct slug is used when checking if the model exists.

Signed-off-by: Mathis <yidhra@tuta.io>
This commit is contained in:
Mathis H (Avnyr) 2024-05-03 13:17:58 +02:00
parent 6ccc899320
commit 438ae4b5d0
Signed by: Mathis
GPG Key ID: DD9E0666A747D126

View File

@ -42,7 +42,7 @@ async function createModel(req: Request, res: Response): Promise<Response> {
async function updateModel(req: Request, res: Response): Promise<Response> { async function updateModel(req: Request, res: Response): Promise<Response> {
const body: IDbModel = req.body; const body: IDbModel = req.body;
const doesExist = await ModelService.getBySlug(`${body.slug_name}`); const doesExist = await ModelService.getBySlug(`${req.params["modelSlug"]}`);
if (!doesExist) { if (!doesExist) {
logger.error("Model does not exist"); logger.error("Model does not exist");
return res.status(404).json({ return res.status(404).json({