@data-fair/lib-vue 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fetch.d.ts +1 -1
- package/fetch.js +1 -0
- package/package.json +1 -1
package/fetch.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ type UseFetchOptions = {
|
|
|
4
4
|
query?: QueryObject | Ref<QueryObject>;
|
|
5
5
|
watch?: Boolean;
|
|
6
6
|
};
|
|
7
|
-
export declare function useFetch<T>(url: string | Ref<string
|
|
7
|
+
export declare function useFetch<T>(url: string | Ref<string> | (() => string), options?: UseFetchOptions): {
|
|
8
8
|
data: [T | null] extends [Ref<any, any>] ? import("@vue/shared").IfAny<Ref<any, any> & T, Ref<Ref<any, any> & T, Ref<any, any> & T>, Ref<any, any> & T> : Ref<import("vue").UnwrapRef<T> | null, T | import("vue").UnwrapRef<T> | null>;
|
|
9
9
|
loading: Ref<boolean, boolean>;
|
|
10
10
|
refresh: () => Promise<void>;
|
package/fetch.js
CHANGED
|
@@ -4,6 +4,7 @@ import { computed, isRef, watch, ref } from 'vue'
|
|
|
4
4
|
import { useUiNotif } from '@data-fair/lib-vue/ui-notif.js'
|
|
5
5
|
export function useFetch (url, options = {}) {
|
|
6
6
|
const { sendUiNotif } = useUiNotif()
|
|
7
|
+
if (typeof url === 'function') { url = computed(url) }
|
|
7
8
|
const fullUrl = computed(() => {
|
|
8
9
|
let fullUrl = isRef(url) ? url.value : url
|
|
9
10
|
const query = isRef(options.query) ? options.query.value : options.query
|