nuxt-api-party icon indicating copy to clipboard operation
nuxt-api-party copied to clipboard

When `immediate` is set to `false`, `pending` is always `true`

Open m-anwr opened this issue 9 months ago • 1 comments

Environment



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

m-anwr avatar Apr 27 '24 12:04 m-anwr

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 avatar Apr 28 '24 18:04 johannschopplich

@johannschopplich Apparently, it's something in useAsyncData indeed. See this issues for reference: https://github.com/nuxt/nuxt/issues/15714

Closing this issue. Thanks!

m-anwr avatar Apr 29 '24 10:04 m-anwr

Thanks for checking upstream. 🙋‍♂️

johannschopplich avatar Apr 29 '24 10:04 johannschopplich