Skip to content

Commit 2372327

Browse files
committed
Allow params to be passed to useGet
1 parent 1b7b207 commit 2372327

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/useGet.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ export default function get(options: UseGetOptions): UseGetData {
5858
function getId(): null | string | number {
5959
return isRef(id) ? id.value : id || null
6060
}
61+
function getParams(): Params {
62+
return isRef(params) ? params.value : params
63+
}
6164

6265
const servicePath = computed<string>(() => model.servicePath)
6366
const state = reactive<UseGetState>({
@@ -111,9 +114,16 @@ export default function get(options: UseGetOptions): UseGetData {
111114
}
112115

113116
watch(
114-
() => [getId(), params],
115-
([id, params]) => {
116-
get(id, params)
117+
() => getId(),
118+
id => {
119+
get(id, getParams())
120+
},
121+
{ lazy }
122+
)
123+
watch(
124+
() => getParams(),
125+
params => {
126+
get(getId(), params)
117127
},
118128
{ lazy }
119129
)

0 commit comments

Comments
 (0)