Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
make-fetch-happen
Advanced tools
The make-fetch-happen npm package is a wrapper around the node-fetch package which provides additional features such as caching, retries, proxy support, and more. It is designed to make HTTP requests in Node.js environments more robust and feature-rich.
Caching
This feature allows make-fetch-happen to cache responses locally, which can be reused for future requests to the same resource, saving bandwidth and time.
const fetch = require('make-fetch-happen').defaults({
cacheManager: './my-cache' // path where cache will be stored
});
fetch('https://example.com').then(response => response.json()).then(data => console.log(data));
Retries
This feature enables automatic retries of failed requests, with customizable settings for the number of retries, delay strategy, and more.
const fetch = require('make-fetch-happen').defaults({
retry: {
retries: 3, // maximum amount of retries
factor: 2, // the exponential factor for delay between retries
minTimeout: 1000 // the number of milliseconds before starting the first retry
}
});
fetch('https://example.com').then(response => response.json()).then(data => console.log(data));
Proxy Support
This feature allows requests to be made through a specified HTTP or HTTPS proxy.
const fetch = require('make-fetch-happen').defaults({
proxy: 'http://myproxy.com:8080'
});
fetch('https://example.com').then(response => response.json()).then(data => console.log(data));
Timeouts
This feature allows setting a maximum time to wait for a response before aborting the request.
const fetch = require('make-fetch-happen').defaults({
timeout: 5000 // time in milliseconds
});
fetch('https://example.com').then(response => response.json()).then(data => console.log(data));
Axios is a popular HTTP client for the browser and Node.js. It supports promise-based API, interceptors, request and response transformations, and automatic transforms for JSON data. Compared to make-fetch-happen, Axios has a larger community and more extensive documentation but does not have built-in caching or offline support.
Got is a human-friendly and powerful HTTP request library for Node.js. It features stream support, promise-based API, and advanced retrying, among other things. Got is comparable to make-fetch-happen in terms of retrying and stream support but differs in its API design and plugin system.
node-fetch is a light-weight module that brings the Fetch API to Node.js. It is a minimalistic and straightforward implementation of the standard without additional features like caching or retries. make-fetch-happen is built on top of node-fetch, adding more advanced features on top of the basic functionality provided by node-fetch.
Superagent is a small progressive client-side HTTP request library, and Node.js module with the same API, sporting many high-level HTTP client features. It is known for its fluent API and chaining capabilities. While it offers features like retries and plugins, it does not have built-in caching like make-fetch-happen.
NOTE: this package is still under heavy development. Please don't use it yet
make-fetch-happen
is a Node.js library that implements the fetch
API in a Node.js-specific way while still providing a lot of the bells and whistles of the standard.
$ npm install --save make-fetch-happen
The make-fetch-happen team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.
10.0.1 (2022-02-09)
FAQs
Opinionated, caching, retrying fetch client
The npm package make-fetch-happen receives a total of 15,438,530 weekly downloads. As such, make-fetch-happen popularity was classified as popular.
We found that make-fetch-happen demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.