add development env var in frontend

pull/1/head
Tao Bror Bojlén 2019-02-21 12:33:07 +00:00
rodzic 795ad67e8b
commit 5b019c87bb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: C6EC7AAB905F9E6F
2 zmienionych plików z 9 dodań i 9 usunięć

Wyświetl plik

@ -22,7 +22,7 @@
"sanitize-html": "^1.18.4" "sanitize-html": "^1.18.4"
}, },
"scripts": { "scripts": {
"start": "react-scripts-ts start", "start": "NODE_ENV=development react-scripts-ts start",
"build": "react-scripts-ts build", "build": "react-scripts-ts build",
"test": "react-scripts-ts test --env=jsdom", "test": "react-scripts-ts test --env=jsdom",
"eject": "react-scripts-ts eject" "eject": "react-scripts-ts eject"

Wyświetl plik

@ -1,11 +1,11 @@
import fetch from 'cross-fetch'; import fetch from "cross-fetch";
const API_ROOT = "https://api.fediverse.space/api/v1/" const API_ROOT =
// const API_ROOT = "http://localhost:8000/api/v1/" process.env.NODE_ENV === "development" ? "http://localhost:8000/api/v1/" : "https://api.fediverse.space/api/v1/";
export const getFromApi = (path: string): Promise<any> => { export const getFromApi = (path: string): Promise<any> => {
const domain = API_ROOT.endsWith("/") ? API_ROOT : API_ROOT + "/"; const domain = API_ROOT.endsWith("/") ? API_ROOT : API_ROOT + "/";
path = path.endsWith("/") ? path : path + "/"; path = path.endsWith("/") ? path : path + "/";
path += "?format=json" path += "?format=json";
return fetch(domain + path).then(response => response.json()); return fetch(domain + path).then(response => response.json());
} };