index.community/frontend/src/util.ts

12 lines
420 B
TypeScript
Raw Normal View History

2018-08-27 21:31:27 +00:00
import fetch from 'cross-fetch';
2019-02-20 20:32:34 +00:00
const API_ROOT = "https://api.fediverse.space/api/v1/"
2018-09-03 21:31:53 +00:00
// 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
}