Skip to content

Commit dcdc1e5

Browse files
committed
Allow useClient to wrap around a custom JsonServiceClient
1 parent b5e4fb8 commit dcdc1e5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/components/AutoQueryGrid.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ import { useConfig } from '@/use/config'
190190
191191
const { config, autoQueryGridDefaults } = useConfig()
192192
const aqd = autoQueryGridDefaults
193-
const client = inject<JsonServiceClient>('client')!
194193
const storage = config.value.storage!
195194
196195
const props = withDefaults(defineProps<{
@@ -240,6 +239,8 @@ const emit = defineEmits<{
240239
(e: "rowSelected", item:any, ev:Event): void
241240
}>()
242241
242+
const client = inject<JsonServiceClient>('client')!
243+
243244
const allAllow = 'filtering,queryString,queryFilters'.split(',') as GridAllowOptions[]
244245
const allShow = 'copyApiUrl,downloadCsv,filtersView,newItem,pagingInfo,pagingNav,preferences,refresh,resetPreferences,toolbar'.split(',') as GridShowOptions[]
245246

src/use/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { inject, provide, ref, watchEffect } from "vue"
44
import { ResponseError, ResponseStatus, ApiResult } from "@servicestack/client"
55
import { unRefs, setRef, swrApi, fromCache, swrCacheKey, createDebounce } from "./utils"
66

7-
export function useClient() {
7+
export function useClient(use?:JsonServiceClient) {
88
/** Maintain loading state whilst API Request is in transit */
99
const loading = ref(false)
1010
/** Maintain API Error in reactive Ref<ResponseStatus> */
1111
const error = ref()
1212
const response = ref()
13-
const client = inject<JsonServiceClient>('client')!
13+
const client = use ?? inject<JsonServiceClient>('client')!
1414

1515
/** Set error state with summary or field validation error */
1616
function setError({ message, errorCode, fieldName, errors }: IResponseStatus) {

0 commit comments

Comments
 (0)