Fix codecheck -> Handle all nullish things possible
This commit is contained in:
parent
bca596fa75
commit
5ab2df351c
@ -39,7 +39,7 @@ async function get(req: Request, res: Response) {
|
|||||||
if (result.length !== 0) {
|
if (result.length !== 0) {
|
||||||
result.forEach((element: { id: number; name: string; code: string | null | boolean }) => {
|
result.forEach((element: { id: number; name: string; code: string | null | boolean }) => {
|
||||||
// code-> true if code is set
|
// 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 });
|
res.status(200).json({ count, result });
|
||||||
} else {
|
} else {
|
||||||
@ -69,7 +69,9 @@ async function get(req: Request, res: Response) {
|
|||||||
if (result.length !== 0) {
|
if (result.length !== 0) {
|
||||||
result.forEach((element: { id: number; name: string; code: string | null | boolean }) => {
|
result.forEach((element: { id: number; name: string; code: string | null | boolean }) => {
|
||||||
// code-> true if code is set
|
// 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 });
|
res.status(200).json({ count, result });
|
||||||
} else {
|
} else {
|
||||||
|
@ -27,7 +27,7 @@ async function get(req: Request, res: Response) {
|
|||||||
// result?.code === null -> user exists and has no code
|
// result?.code === null -> user exists and has no code
|
||||||
// result?.code === undefined -> user does not exists
|
// result?.code === undefined -> user does not exists
|
||||||
// value.code === result?.code -> If user exists and has no code this matches
|
// 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);
|
//log.api?.debug(result, result?.code);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user