nuxt-api-party
nuxt-api-party copied to clipboard
When `immediate` is set to `false`, `pending` is always `true`
Environment
- Operating System: Linux
- Node Version: v18.16.0
- Nuxt Version: 3.11.2
- CLI Version: 3.11.1
- Nitro Version: 2.9.6
- Package Manager: [email protected]
- Builder: -
- User Config: ssr, runtimeConfig, devtools, css, modules, vue, imports, apiParty, image
- Runtime Modules: @nuxtjs/[email protected], @vueuse/[email protected], @pinia/[email protected], [email protected], [email protected], @nuxt/[email protected]
- Build Modules: -
Reproduction
const {
data,
pending,
} = await useApiData("/posts", {
method: "GET",
query: computed(() => ({ query: searchTerm.value })),
watch: false,
immediate: false, // <-- when this is commented out, `pending` behaves correctly
default: () => [],
});
Describe the bug
When I set immediate
option to false
, the pending
Ref is always true
Additional context
No response
Logs
No response
Hi there!
I wonder if this is a bug in useAsyncData
from Nuxt itself. Because under the hood, this module passes options like immediate
to useAsyncData
: https://github.com/johannschopplich/nuxt-api-party/blob/78f30a3355a4c1dc403744ce7be626c5f14f1138/src/runtime/composables/useApiData.ts#L176
Can you please provide a minimal reproduction with tests for both Nuxt API Party and a plain example with useAsyncData
? Thanks in advance. You can use the templates below:
👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz
👉 https://codesandbox.io/p/github/nuxt/starter/v3-codesandbox
@johannschopplich Apparently, it's something in useAsyncData
indeed.
See this issues for reference: https://github.com/nuxt/nuxt/issues/15714
Closing this issue. Thanks!
Thanks for checking upstream. 🙋♂️