Introducing Undici@4

Why Undici

Notable Changes

WASM Parser

Redirect Support

Native Mock

import { request, MockAgent, setGlobalDispatcher } from './index.js'const agent = new MockAgent()agent.disableNetConnect()
agent.get('http://localhost:3000')
.intercept({
path: '/foo',
method: 'GET'
})
.reply(200, 'hello world')
setGlobalDispatcher(agent)const {
statusCode,
headers,
trailers,
body
} = await request('http://localhost:3000/foo')
console.log('response received', statusCode)
console.log('headers', headers)
body.setEncoding('utf8')
for await (const data of body) {
console.log('data', data)
}
console.log('trailers', trailers)

Website and Documentation

Dispatcher instead of Agent

Support Node v12.x

What’s next?

Benchmarks

Thanks

--

--

--

Node.js is a collaborative open source project dedicated to building and supporting the Node.js platform. https://nodejs.org/en/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Week 1: Thoughts & P5.js Drawing Assignment

Screenshot of the code in the p5.js Web Editor and the drawing in geometrics shape of two cactuses in a pot.

Avoid z-indexes whenever possible

Integrating Firebase Auth into Strapi.

VScode plugins that helped me be more productive!

Event Handling and State Management in Angular

Is Vanilla.js a Good Choice?

Valuation of NFTs

Angular 11 New Features

Angular 11 New Features

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Node.js

Node.js

Node.js is a collaborative open source project dedicated to building and supporting the Node.js platform. https://nodejs.org/en/

More from Medium

Serverless JAMstack with NuxtJS, FaunaDB, GraphQL and Netlify

Reliable IP Geolocation with Superface

Generating Open Source License Disclaimers with Yarn

THE FOLLOWING SETS FORTH ATTRIBUTION NOTICES FOR THIRD PARTY SOFTWARE THAT MAY BE CONTAINED IN PORTIONS OF THE…

Containerizing Go + React & Automating w/ GitHub Actions | Part 1