mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 12:56:01 +00:00
22 lines
462 B
TypeScript
22 lines
462 B
TypeScript
import _ from 'lodash';
|
|
import axiosInstance from './axiosInstance';
|
|
import { writable } from 'svelte/store';
|
|
|
|
export default function useFetch({ url, data = undefined, params = undefined, defaultValue = undefined, ...config }) {
|
|
const result = writable(defaultValue);
|
|
|
|
axiosInstance
|
|
.request({
|
|
method: 'get',
|
|
params,
|
|
url,
|
|
data,
|
|
...config,
|
|
})
|
|
.then(resp => {
|
|
result.set(resp.data);
|
|
});
|
|
|
|
return result;
|
|
}
|