Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useLazyFetch does not work with reactive values #1135

Closed
vitaly-petras opened this issue Mar 8, 2024 · 5 comments · Fixed by #1137
Closed

useLazyFetch does not work with reactive values #1135

vitaly-petras opened this issue Mar 8, 2024 · 5 comments · Fixed by #1137

Comments

@vitaly-petras
Copy link

vitaly-petras commented Mar 8, 2024

Environment

Reproduction

Nuxt3 working example

Nuxt + bridge not working

Describe the bug

I want to use reactive values in useLazyFetch function, but nuxt bridge seems to not support this.

`const username = ref("");
const password = ref("");

const queryParams = computed(() => ({
username: username.value,
password: password.value,
}));

const { data, pending, error, refresh } = useLazyFetch("/login", {
query: queryParams
});`

Snímek obrazovky 2024-03-08 v 6 24 11

I tried to use not computed, but refs. Seems to work => values are updated after every send request, but it sends not the value itself but object {value: 'value of input'}

`const username = ref("");
const password = ref("");

const { data, pending, error, refresh } = useLazyFetch("/login", {
query: {
username: username,
password: password,
}
});`

Snímek obrazovky 2024-03-08 v 6 23 56

In nuxt3 version all working fine, so there must a bug in bridge version of function useLazyFetch.

Additional context

No response

Logs

logs are in reproduction links
@vitaly-petras
Copy link
Author

hey @wattanx thank you for your quick response to this issue. When do you think your pull request will be resolved? It seems good and I would love to start using this :)

@wattanx
Copy link
Collaborator

wattanx commented Mar 12, 2024

This is a big change and we are checking it carefully. It will take a little longer to release.

@vitaly-petras
Copy link
Author

@wattanx, I found a BUG, you fixed it, all are happy, but not untill this ticket is merged and closed. I dont understand why it already isnt..
How can developers use funkction useLazyFetch if it is a buggy and not working? Isnt it an important bug? Fetching is the most often functionality fot nuxt apps.. Guys please check this out and make merge happen please :)

@wattanx
Copy link
Collaborator

wattanx commented Mar 20, 2024

If you want a quick fix, use patch-package.
https://www.npmjs.com/package/patch-package

Please read the following statement as to why we do not merge immediately.
https://github.com/pi0/tired-maintainer?tab=readme-ov-file#this-pr-looks-good-to-me-or-tell-me-what-to-do

@vitaly-petras
Copy link
Author

Thank you! I solved my issue by pnpm patch and all working nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants