Skip to main content
Version: 6.x

Fetch

Undici exposes a fetch() method starts the process of fetching a resource from the network.

Documentation and examples can be found on MDN.

FormData

This API is implemented as per the standard, you can find documentation on MDN.

If any parameters are passed to the FormData constructor other than undefined, an error will be thrown. Other parameters are ignored.

Response

This API is implemented as per the standard, you can find documentation on MDN

Request

This API is implemented as per the standard, you can find documentation on MDN

This API is implemented as per the standard, you can find documentation on MDN

Body Mixins

Response and Request body inherit body mixin methods. These methods include:

There is an ongoing discussion regarding .formData() and its usefulness and performance in server environments. It is recommended to use a dedicated library for parsing multipart/form-data bodies, such as Busboy or @fastify/busboy.

These libraries can be interfaced with fetch with the following example code:

import { Busboy } from '@fastify/busboy'
import { Readable } from 'node:stream'

const response = await fetch('...')
const busboy = new Busboy({
headers: {
'content-type': response.headers.get('content-type')
}
})

Readable.fromWeb(response.body).pipe(busboy)