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

ACA Javascript-201

React Native Secure Storage (rn-secure-storage)

Role-Based Access Control in Angular with Nebular Security, ACL, and JWT

Getting started with Go Ethereum

Thinking In React

10 Bad Habits Most Programmers Develop Eventually Without Realising

The Developers Guide to Redux-like State Management in Angular while Keeping it a Secret

Best apple macbook

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

We open-sourced our Node.js API generator

Create a Node.js Video Streaming Application

GraphQL, Apollo Studio, and Cookies

FastAPI vs. Express.js vs. Flask vs. Nest.js Benchmark