Created
June 22, 2020 08:34
-
-
Save yoshuawuyts/eb6ff719511f760ccceb9d299ce4777a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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