From 0c5b06586831ca2bfd8f604dcf93ac87c0465da0 Mon Sep 17 00:00:00 2001 From: Henry Wilson Date: Tue, 30 Apr 2024 17:03:53 -0400 Subject: [PATCH] further env var tweaks --- packages/grant-explorer/src/features/api/gap.ts | 4 ++-- packages/grant-explorer/src/features/api/oso.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/grant-explorer/src/features/api/gap.ts b/packages/grant-explorer/src/features/api/gap.ts index 672526fdb5..fbabac3026 100644 --- a/packages/grant-explorer/src/features/api/gap.ts +++ b/packages/grant-explorer/src/features/api/gap.ts @@ -2,7 +2,7 @@ import { useState } from "react"; import useSWR from "swr"; import { Hex } from "viem"; -const indexerUrl = process.env.REACT_APP_KARMA_GAP_INDEXER_URL as string; +const indexerUrl = process.env.REACT_APP_KARMA_GAP_INDEXER_URL as string || ""; export interface IGrantStatus { uid: Hex; @@ -33,7 +33,7 @@ export function useGap(projectId?: string) { const [grants, setGrants] = useState([]); const getGrantsFor = async (projectRegistryId: string) => { - if (indexerUrl === undefined) throw new Error("GAP Indexer url not set."); + if (indexerUrl === "") throw new Error("GAP Indexer url not set."); try { const items: IGapGrant[] = await fetch( `${indexerUrl}/grants/external-id/${projectRegistryId}` diff --git a/packages/grant-explorer/src/features/api/oso.ts b/packages/grant-explorer/src/features/api/oso.ts index 22c009c6f0..5e4fc6962d 100644 --- a/packages/grant-explorer/src/features/api/oso.ts +++ b/packages/grant-explorer/src/features/api/oso.ts @@ -3,7 +3,7 @@ import useSWR from "swr"; import { Hex } from "viem"; import { gql, GraphQLClient } from "graphql-request"; -const osoApiKey = process.env.REACT_APP_OSO_API_KEY as string; +const osoApiKey = process.env.REACT_APP_OSO_API_KEY as string || ""; const osoUrl = "https://opensource-observer.hasura.app/v1/graphql"; const graphQLClient = new GraphQLClient(osoUrl, { headers: { @@ -88,7 +88,7 @@ export function useOSO(projectGithub?: string) { const [stats, setStats] = useState(null); const getStatsFor = async (projectRegistryGithub: string) => { - if (osoApiKey === undefined) throw new Error("OpenSourceObserver API key not set."); + if (osoApiKey === "") throw new Error("OpenSourceObserver API key not set."); const queryId = gql`{ artifacts_by_project(where: {artifact_name: {_ilike: "%${projectRegistryGithub}/%"}} distinct_on: project_id