query grid

This commit is contained in:
Jan Prochazka
2021-03-08 20:00:51 +01:00
parent 904d35d26a
commit a35d5525a3
10 changed files with 244 additions and 19 deletions

View File

@@ -8,7 +8,6 @@ export default function memberStore(store, extractStore) {
if (unsubscribeSub) unsubscribeSub();
unsubscribeSub = subStore.subscribe(subValue => {
if (res) {
console.log('subValue', subValue);
res.set(subValue);
} else {
res = writable(subValue);

View File

@@ -0,0 +1,21 @@
import _ from 'lodash';
import axios from './axios';
import { writable } from 'svelte/store';
export default function useFetch({ url, data = undefined, params = undefined, defaultValue = undefined, ...config }) {
const result = writable(defaultValue);
axios
.request({
method: 'get',
params,
url,
data,
...config,
})
.then(resp => {
result.set(resp.data);
});
return result;
}