const program = Effect.gen(function* () {
const client = yield* HttpClient.HttpClient;
const response = yield* client.post('https://...', {
acceptJson: true,
body: yield* HttpBody.json({ ... }),
});
const json = yield* response.json;
console.dir(json, { depth: null });
}).pipe(
Effect.provide(NodeHttpClient.layerWithoutAgent),
Effect.provide(
NodeHttpClient.makeAgentLayer({
cert: readFileSync('cert.pem', 'utf-8').trim(),
key: readFileSync('key.pem', 'utf-8').trim(),
passphrase: readFileSync('pass.txt', 'utf-8').trim(),
})
)
);
await Effect.runPromise(program);
const program = Effect.gen(function* () {
const client = yield* HttpClient.HttpClient;
const response = yield* client.post('https://...', {
acceptJson: true,
body: yield* HttpBody.json({ ... }),
});
const json = yield* response.json;
console.dir(json, { depth: null });
}).pipe(
Effect.provide(NodeHttpClient.layerWithoutAgent),
Effect.provide(
NodeHttpClient.makeAgentLayer({
cert: readFileSync('cert.pem', 'utf-8').trim(),
key: readFileSync('key.pem', 'utf-8').trim(),
passphrase: readFileSync('pass.txt', 'utf-8').trim(),
})
)
);
await Effect.runPromise(program);