Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.5k
docs: add parallel data fetching tip in best practices section#33815
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
docs: add parallel data fetching tip in best practices section#33815
Uh oh!
There was an error while loading.Please reload this page.
Conversation
|
WalkthroughThe change adds documentation to the performance best practices guide. Specifically, it includes a code example demonstrating how to execute multiple API calls concurrently using Promise.all within useAsyncData, as an alternative to sequential request patterns. The documentation shows the implementation approach for parallel requests. No functional code changes or error-handling modifications are made. No public declarations are altered. Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Tip ✨ Issue Enrichment is now available for GitHub issues!CodeRabbit can now help you manage issues more effectively:
Disable automatic issue enrichmentTo disable automatic issue enrichment, add the following to your issue_enrichment:auto_enrich:enabled:false Thanks for usingCodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
docs/3.guide/2.best-practices/performance.md (2)
115-124:Consider showing how to destructure or access the returned data.The example returns an array from
Promise.all, sodatawill contain[products, shoes]. For clarity, you might want to show destructuring or accessing individual results:const{ data}=awaituseAsyncData(()=>{returnPromise.all([$fetch("/api/products/"),$fetch("/api/category/shoes")]);});// data will be [productsArray, shoesArray]// Or destructure: const [products, shoes] = data.valueThis helps readers understand the structure of the returned data immediately.
115-124:Document error-handling expectations for Promise.all.While the example is correct, it's worth noting in the surrounding prose (or as an inline comment) that if any API call rejects, the entire
Promise.allfails. For production code, consider mentioning alternatives likePromise.allSettledwhen partial failures are acceptable.This addition strengthens the "best practices" aspect of the guide without complicating the basic example.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/3.guide/2.best-practices/performance.md(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-10T14:42:56.647Z
Learnt from: TofandelRepo: nuxt/nuxt PR: 33192File: test/nuxt/use-async-data.test.ts:366-373Timestamp: 2025-09-10T14:42:56.647ZLearning: In the Nuxt useAsyncData test "should watch params deeply in a non synchronous way", the foo watcher intentionally updates both params.foo and params.locale using locale.value, simulating a scenario where one watcher consolidates multiple reactive values into a shared params object for testing debounced/non-synchronous behavior.Applied to files:
docs/3.guide/2.best-practices/performance.md
🪛 LanguageTool
docs/3.guide/2.best-practices/performance.md
[uncategorized] ~125-~125: Loose punctuation mark.
Context: ..."/api/category/shoes") ]); }); ``` :read-more{title="Data fetching" to="/doc...
(UNLIKELY_OPENING_PUNCTUATION)
🔇 Additional comments (1)
docs/3.guide/2.best-practices/performance.md (1)
115-124:Code pattern is sound and well-placed.The Promise.all pattern is the correct idiomatic approach for parallel requests in Nuxt, and the placement immediately after the
useFetch/useAsyncDataexplanation makes logical sense. The example is practical and concise.
📚 Description
This PR adds a small section about how to avoid waterfall effect when you need to do multiple API calls. The suggestion is to use
Promise.allto fetch in parallel to improve performance.