Skip to content

Instantly share code, notes, and snippets.

@hinst
Last active February 24, 2021 11:11
Show Gist options
  • Save hinst/0d75224e50bcaf70633df26a10c0aa7e to your computer and use it in GitHub Desktop.
Save hinst/0d75224e50bcaf70633df26a10c0aa7e to your computer and use it in GitHub Desktop.
agent for node-fetch
import http from 'http';
import https from 'https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
const agent = (_parsedURL: URL) => _parsedURL.protocol == 'https:' ? httpsAgent : httpAgent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment