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

790 B
Raw Blame
import {
  HttpMethod,
  httpClient,
  AuthenticationType,
} from '@activepieces/pieces-common';
import { BASE_URL } from './constants';
import { isNil } from '@activepieces/pieces-framework';

export async function enrichlayerApiCall(
  auth: string,
  path: string,
  queryParams: Record<string, string | undefined>,
) {
  const filteredParams: Record<string, string> = {};
  for (const [key, value] of Object.entries(queryParams)) {
    if (!isNil(value) && value !== '') {
      filteredParams[key] = value;
    }
  }

  const response = await httpClient.sendRequest({
    method: HttpMethod.GET,
    url: `${BASE_URL}${path}`,
    authentication: {
      type: AuthenticationType.BEARER_TOKEN,
      token: auth,
    },
    queryParams: filteredParams,
  });
  return response.body;
}