You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
This library is compatible with VueUseuseFetch(), andurl returned fromuseUrl() can easily be used to triggerauto-reftech if option{ refetch: true } is passed touseFetch() which make for intuitive and easy way to work withurl parametes and variables without the need to modify url string directly
How to use debouncing, throttling and other reactive backpressures with useUrl():
import{useFetch,useDebounce}from"@vueuse/core"import{useUrl}from'vue-useurl'import{ref}from'vue-demi'exportfunctionuseApi(){constsearch=ref('query')//constfilters=ref(['filter1','filter2','filter3'])// declare reactive varibalesconst{ url, queryParams, pathVariables, hash, path, disableCSV}=useUrl({path:'/api/v1/users/:id/search',pathVariables:{id:451},queryParams:{search:useDebounce(search,500),//limit:50,page:12,sort:'CreatedOn',types:useDebounce(filters,3500)// then pass their reactive backpressure objects instead},hash:'hashtag',disableCSV:false},'http://api.com')const{ isFetching, error, data}=useFetch(url,{initialData:{results:[]},refetch:true}).get().json()return{data,search,//filters,// changing this now will trigger the url re-buildqueryParams,pathVariables,hash,path,url}}