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

feat(nuxt): return status from useAsyncData #21045

Merged
merged 7 commits into from
Jun 9, 2023

Conversation

nicolaspayot
Copy link
Contributor

@nicolaspayot nicolaspayot commented May 24, 2023

πŸ”— Linked issue

resolves #18810

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

  • This PR introduces a new status property in the object returned by the composables useAsyncData / useFetch and their lazy variations.
  • This status property is a ref<string> that can contain the following values:
    • idle -> when request did not start
      • ({ immediate: false } and execute not called yet
      • { server: false } -> status should be idle on server side
    • pending -> when started
    • success -> when request succeeded
    • error -> when request failed
  • It aims to bring a more powerful way to track the status of an async data request. Relying on pending flag only has a limitation detailed in this issue.
  • Resolves status property for useAsyncData/useFetch ( lazy equivalents)Β #18810

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@nuxt-studio
Copy link

nuxt-studio bot commented May 24, 2023

βœ… Live Preview ready!

Name Edit Preview Latest Commit
Nuxt Docs Edit on Studio β†—οΈŽ View Live Preview a82013f

@nicolaspayot nicolaspayot marked this pull request as ready for review May 24, 2023 15:51
Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is beautifully done - thank you ❀️

docs/3.api/1.composables/use-async-data.md Outdated Show resolved Hide resolved
@danielroe danielroe requested a review from lihbr May 26, 2023 15:29
@danielroe danielroe changed the title feat(nuxt): add status property in asyncData requests feat(nuxt): return status from useAsyncData Jun 9, 2023
@danielroe danielroe merged commit c884a95 into nuxt:main Jun 9, 2023
23 checks passed
@github-actions github-actions bot mentioned this pull request Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

status property for useAsyncData/useFetch ( lazy equivalents)
2 participants