UseAsyncData with a request params defined by a computed property ?
Should that work ?
directusGetItems is a function I defined using the directus base url.
I would like to use the computed prop to modify the requestParams in the UI.
in this example, it's not reactive, but this non reactive version is not working. It doesn't fetch data on page load.
Is it possible to use useAsyncData with a computed prop ?
6 Replies
The computed is called
requestParams
while you use reqParam
in your method.
You also need to use requestParams.value
thanks for you answer ! yep sorry. this is a simplified version to make the question easier to understand, and I made somt typos when rewiting it. in my code these errors were fine. Do you know if it should technicaly work ? useAsyncData with a computed prop as queryParameters ?
I don't see any problem with using a computed prob within useAsnycData.
You should not expect it to re-execute the useAsyncData method in case your requestParams computed returns a changed value.
I shouldn't expect it to re-execute it? oh. I thought that's what the goal is... what does that watch param do then ?
Oh i missed on that one. Yes that will indeed handle the re-execution in case reqParam aka requestParams does change.
Try using
watch: [requestParams]
Thanks for your help. I finaly took another approach, but I managed to get this to work. thanks!