forwardemail / forwardemail/superagent
using a custom http.Agent (extend documentation)
- Dominant language
- JavaScript
- Stars
- 16.6k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
I was searching for a solution to use a custom http.Agent for every request. In early 3.x releases, it was possible to do something like (ref: #1130):
```javascript
const http = require('http')
const request = require('superagent')
const myAgent = new http.Agent()
request(method, url).agent(myAgent)
```
With the PR #1302 the `.agent()` method only accepts some options, but no http.Agent instance.
My solution was to inject a middleware function with `.use(...)`.
Is there any better solution for this scenario?
I would suggest to extend the documentation about using custom http.Agent and `superagent.agent().use()`.
My solution:
```javascript
const myAgent = new http.Agent()
const request = superagent.agent().use(req => req.agent(myAgent))
```
Contributor guide
Assessment
This issue has not been assessed yet.