package-rebuilds/pkgs/node-undici/node-undici-5.28.4+dfsg1+~cs23.12.11/examples/proxy-agent.js
Fabian Grünbichler afee63929c add node-undici for libgit2 1.8.1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-09-10 11:23:24 +02:00

26 lines
549 B
JavaScript

'use strict'
const { request, setGlobalDispatcher, ProxyAgent } = require('../')
setGlobalDispatcher(new ProxyAgent('http://localhost:8000/'))
async function main () {
const {
statusCode,
headers,
trailers,
body
// send the request via the http://localhost:8000/ HTTP proxy
} = await request('http://localhost:3000/undici')
console.log('response received', statusCode)
console.log('headers', headers)
for await (const data of body) {
console.log('data', data)
}
console.log('trailers', trailers)
}
main()