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

When using useFetch form is submitted for each key press #25426

Closed
getshcc opened this issue Jan 24, 2024 · 1 comment
Closed

When using useFetch form is submitted for each key press #25426

getshcc opened this issue Jan 24, 2024 · 1 comment

Comments

@getshcc
Copy link

getshcc commented Jan 24, 2024

Environment

  • Operating System: Windows_NT
  • Node Version: v21.6.0
  • Nuxt Version: ^3.2.3
  • Nitro Version: ^2.2.3
  • Package Manager: unknown
  • Builder: webpack
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/getshcc/nuxt-auth

Describe the bug

when using useFetch in *.vue file after submit form for first time. The form is submitted for each key press.

Mongodb:
useFetch-2024-25-1

Additional context

when i changed useFetch to $fetch problem fixed.

Logs

No response

@warflash
Copy link
Member

You shouldn't register useFetch inside a function, it should almost always be on the top level scope.
Here's a video explaining why and how to properly use it: https://www.youtube.com/watch?v=njsGVmcWviY, alternatively note the info box in the docs: https://nuxt.com/docs/api/composables/use-fetch

@warflash warflash closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants