add development env var in frontend
This commit is contained in:
parent
795ad67e8b
commit
5b019c87bb
|
@ -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"
|
||||||
|
|
|
@ -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());
|
||||||
}
|
};
|
||||||
|
|
Loading…
Reference in a new issue