apiCall POC

This commit is contained in:
Jan Prochazka
2021-12-22 09:37:53 +01:00
parent f0e0fb8f64
commit 148af24b2c
6 changed files with 40 additions and 30 deletions

View File

@@ -0,0 +1,18 @@
import resolveApi, { resolveApiHeaders } from './resolveApi';
export async function apiCall(route: string, args: {} = undefined) {
const resp = await fetch(`${resolveApi()}/${route}`, {
method: 'POST',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
...resolveApiHeaders(),
},
body: JSON.stringify(args),
});
return resp.json();
}
export function apiOn(event: string, hander: Function) {}
export function apiOff(event: string, hander: Function) {}