Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_POLICYENGINE_API=https://api.policyengine.org
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ REACT_APP_DEBUG ?= false

install:
npm ci
cp .env.example .env
pip3 install -U black

build:
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/api/call.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { renderHook } from "@testing-library/react";
import { useAuthenticatedApiCall } from "../../api/call";
import * as authenticatedFetch from "../../hooks/useAuthenticatedFetch";
import { POLICYENGINE_API } from "../../constants";

jest.mock("../../hooks/useAuthenticatedFetch");
let mock_authenticated_fetch;
Expand Down Expand Up @@ -36,7 +37,7 @@ describe("useAuthenticatedApiCall", () => {

expect(response).toEqual(DEFAULT_FETCH_RESULT);
expect(mock_authenticated_fetch.mock.calls[0]).toEqual([
"https://api.policyengine.org/test/path",
POLICYENGINE_API + "/test/path",
{
body: JSON.stringify(SOME_REQUEST_BODY),
headers: {
Expand Down
3 changes: 1 addition & 2 deletions src/api/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { buildParameterTree } from "./parameters";
import { buildVariableTree, getTreeLeavesInOrder } from "./variables";
import { wrappedJsonStringify, wrappedResponseJson } from "../data/wrappedJson";
import { useAuthenticatedFetch } from "../hooks/useAuthenticatedFetch";

const POLICYENGINE_API = "https://api.policyengine.org";
import { POLICYENGINE_API } from "../constants";

/**
* returns an api call function that can be used to make requests
Expand Down
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const POLICYENGINE_API =
process.env.REACT_APP_POLICYENGINE_API || "https://api.policyengine.org";
Loading