Skip to content

Commit 3edffa0

Browse files
committed
Fix the watcher for useGet
I forgot that you have to listen to `.value` on a computed property.
1 parent 3cdd511 commit 3edffa0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/useGet.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ export default function get(options: UseGetOptions): UseGetData {
5555
options
5656
)
5757

58-
const _id = computed(() => id)
58+
function getId(): null | string | number {
59+
return isRef(id) ? id.value : id || null
60+
}
61+
5962
const servicePath = computed<string>(() => model.servicePath)
6063
const state = reactive<UseGetState>({
6164
item: computed(() => {
@@ -80,7 +83,7 @@ export default function get(options: UseGetOptions): UseGetData {
8083
isLocal: local
8184
})
8285

83-
function get<T>(id, params): T {
86+
function get<T>(id, params?: Params): T {
8487
const idToUse = isRef(id) ? id.value : id
8588
const paramsToUse = isRef(params) ? params.value : params
8689

@@ -108,9 +111,9 @@ export default function get(options: UseGetOptions): UseGetData {
108111
}
109112

110113
watch(
111-
() => [_id, params],
112-
([_id, params]) => {
113-
get(_id, params)
114+
() => [getId(), params],
115+
([id, params]) => {
116+
get(id, params)
114117
},
115118
{ lazy }
116119
)

0 commit comments

Comments
 (0)