Skip to content

docs: add Getting Started guide#5371

Merged
mcollina merged 2 commits into
nodejs:mainfrom
AliMahmoudDev:docs/getting-started-guide
Jun 7, 2026
Merged

docs: add Getting Started guide#5371
mcollina merged 2 commits into
nodejs:mainfrom
AliMahmoudDev:docs/getting-started-guide

Conversation

@AliMahmoudDev

Copy link
Copy Markdown
Contributor

addresses #2208

adds a Getting Started guide covering the most common undici use cases:

  • fetch for simple requests
  • request / stream / pipeline for more control
  • when to use Client vs Pool vs Agent
  • timeouts and error handling
  • common patterns (proxies, mocking, global install)
  • links to relevant API docs and best practices for deeper reading

@codecov-commenter

codecov-commenter commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.25%. Comparing base (a8ea6f2) to head (44afc12).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5371   +/-   ##
=======================================
  Coverage   93.25%   93.25%           
=======================================
  Files         110      110           
  Lines       36738    36738           
=======================================
+ Hits        34259    34260    +1     
+ Misses       2479     2478    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread docs/docs/GettingStarted.md
Comment thread docs/docs/GettingStarted.md Outdated
import { createWriteStream } from 'node:fs'

const res = await fetch('https://example.com/large-file.zip')
Readable.fromWeb(res.body).pipe(createWriteStream('./file.zip'))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This has a few problems. The actual solution is to use pipeline from node:stream with res.body and createWriteStream.

Comment thread docs/docs/GettingStarted.md Outdated
| `fetch` | Quick requests, standard API compatibility, JSON/form bodies |
| `request` | Maximum throughput, reading response headers, fine-grained control |
| `stream` | Piping responses directly to a writable stream |
| `pipeline` | Streaming request bodies combined with streaming responses |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would not document this here, and ideally not even stream.

@AliMahmoudDev

Copy link
Copy Markdown
Contributor Author

pushed -- added a Request object example, switched the streaming snippet to use pipeline from node:stream/promises, and removed the stream/pipeline sections and the method comparison table.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 8464ab7 into nodejs:main Jun 7, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants