Skip to content

Instantly share code, notes, and snippets.

@yoshuawuyts
Created June 22, 2020 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoshuawuyts/eb6ff719511f760ccceb9d299ce4777a to your computer and use it in GitHub Desktop.
Save yoshuawuyts/eb6ff719511f760ccceb9d299ce4777a to your computer and use it in GitHub Desktop.
const { Client } = require('undici')
const client = new Client(`unix:///tmp/hello.sock`)
client.request({
path: '/',
method: 'GET'
}, function (err, data) {
if (err) throw err
const {
statusCode,
headers,
body
} = data
console.log('response received', statusCode)
console.log('headers', headers)
body.setEncoding('utf8')
body.on('data', console.log)
client.close()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment