index.community/frontend/src/util.ts

12 lines
416 B
TypeScript
Raw Normal View History

2018-08-27 21:31:27 +00:00
import fetch from 'cross-fetch';
// const API_ROOT = "https://fediverse.space/api/v1/"
const API_ROOT = "http://localhost:8000/api/v1/"
2018-08-27 21:31:27 +00:00
export const getFromApi = (path: string): Promise<any> => {
const domain = API_ROOT.endsWith("/") ? API_ROOT : API_ROOT + "/";
path = path.endsWith("/") ? path : path + "/";
path += "?format=json"
return fetch(domain + path).then(response => response.json());
2018-08-27 21:31:27 +00:00
}