4lessandrodev/ts-logs

On extract tags from request ensure data is not array

Closed this issue · 0 comments

// get-step-data-from-request.util.ts 

export const getStepDataFromRequest = (err: Error, req: Requests): StepDataFromRequest => {

    const body = extractBodyAsObject<{}>(req?.body ?? {});

   // ensure body is not array here
    const hasData = typeof body === 'object' && (Object.keys(body ?? {}).length > 0);

    const tags = hasData ? Object.keys(body) : [];

}

Because

typeof []
'object'