Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

403 B
Raw Blame
function omitEmptyValues<T extends object>(body: T): Partial<T> {
  const result: Partial<T> = {};
  for (const key in body) {
    if (!isEmptyValue(body[key])) {
      result[key] = body[key];
    }
  }
  return result;
}

function isEmptyValue(value: unknown): boolean {
  return value === '' || (Array.isArray(value) && value.length === 0);
}

export const requestBodyUtils = {
  omitEmptyValues,
};