docs: add Getting Started guide by AliMahmoudDev · Pull Request #5371 · nodejs/undici (original) (raw)

@AliMahmoudDev

addresses #2208

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

@AliMahmoudDev

@codecov-commenter

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

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

🚀 New features to boost your workflow:

mcollina

import { createWriteStream } from 'node:fs'
const res = await fetch('https://example.com/large-file.zip')
Readable.fromWeb(res.body).pipe(createWriteStream('./file.zip'))

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.

| | `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 | |

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

… streaming, remove stream/pipeline docs

@AliMahmoudDev

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

Choose a reason for hiding this comment

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

lgtm

This was referenced

Jun 8, 2026

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})