2019-02-21 12:33:07 +00:00
|
|
|
import fetch from "cross-fetch";
|
2018-08-27 21:31:27 +00:00
|
|
|
|
2019-02-21 12:33:07 +00:00
|
|
|
const API_ROOT =
|
2019-07-14 11:47:06 +00:00
|
|
|
process.env.NODE_ENV === "development" ? "http://localhost:4000/api/" : "https://backend.fediverse.space/api/";
|
2018-08-27 21:31:27 +00:00
|
|
|
|
|
|
|
export const getFromApi = (path: string): Promise<any> => {
|
2019-02-21 12:33:07 +00:00
|
|
|
const domain = API_ROOT.endsWith("/") ? API_ROOT : API_ROOT + "/";
|
|
|
|
path = path.endsWith("/") ? path : path + "/";
|
|
|
|
return fetch(domain + path).then(response => response.json());
|
|
|
|
};
|