diff --git a/src/routes/api/v1/user.ts b/src/routes/api/v1/user.ts index 7f32161..107e41b 100644 --- a/src/routes/api/v1/user.ts +++ b/src/routes/api/v1/user.ts @@ -39,7 +39,7 @@ async function get(req: Request, res: Response) { if (result.length !== 0) { result.forEach((element: { id: number; name: string; code: string | null | boolean }) => { // code-> true if code is set - element.code = element.code !== ''; + element.code = !(element.code === '' || element.code === null || element.code === undefined); // Check if nullish }); res.status(200).json({ count, result }); } else { @@ -69,7 +69,9 @@ async function get(req: Request, res: Response) { if (result.length !== 0) { result.forEach((element: { id: number; name: string; code: string | null | boolean }) => { // code-> true if code is set - element.code = element.code !== ''; + //log.api?.debug('"' + element.code + '"'); + //log.api?.debug(!(element.code === ''), !(element.code === null), !(element.code === undefined)); + element.code = !(element.code === '' || element.code === null || element.code === undefined); // Check if nullish }); res.status(200).json({ count, result }); } else { diff --git a/src/routes/api/v1/user_codecheck.ts b/src/routes/api/v1/user_codecheck.ts index 60c7833..3adeddc 100644 --- a/src/routes/api/v1/user_codecheck.ts +++ b/src/routes/api/v1/user_codecheck.ts @@ -27,7 +27,7 @@ async function get(req: Request, res: Response) { // result?.code === null -> user exists and has no code // result?.code === undefined -> user does not exists // value.code === result?.code -> If user exists and has no code this matches - res.status(200).json(result?.code === '' || result?.code === null || result?.code === undefined || value.code === result?.code); + res.status(200).json(result?.code === '' || result?.code === null || result?.code === undefined || result?.code === value.code); //log.api?.debug(result, result?.code); }); }