mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-25 04:06:01 +00:00
query grid
This commit is contained in:
21
packages/web/src/utility/useFetch.ts
Normal file
21
packages/web/src/utility/useFetch.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user