complete removed axiosInstance

This commit is contained in:
Jan Prochazka
2021-12-22 10:59:00 +01:00
parent f9c54cdce2
commit 05ea435820
66 changed files with 41 additions and 157 deletions

View File

@@ -1,4 +1,5 @@
import resolveApi, { resolveApiHeaders } from './resolveApi';
import { writable } from 'svelte/store';
export async function apiCall(route: string, args: {} = undefined) {
const resp = await fetch(`${resolveApi()}/${route}`, {
@@ -16,3 +17,15 @@ export async function apiCall(route: string, args: {} = undefined) {
export function apiOn(event: string, hander: Function) {}
export function apiOff(event: string, hander: Function) {}
import _ from 'lodash';
export function useApiCall(route, args, defaultValue) {
const result = writable(defaultValue);
apiCall(route, args).then(resp => {
result.set(resp);
});
return result;
}