
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
node-wget-fetch
Advanced tools
Ultra simple async retrieval of resources or remote files over http or https, an cli tool, and convenience wrapper of node-fetch.
Ultra simple async retrieval of resources or remote files over http or https, an cli tool, and convenience wrapper of node-fetch.
npm install node-wget-fetch
fetching(url
, action = destination
| response_body_type
| options
[, options
])
url
A string representing an absolute url
action
Save to destination or body action on response type or use for options
response type can be:
header
' for all response headers - raw()object
' for the response object - no post/pre processingarray
' for arrayBuffer()buffer
' for buffer()blob
' for blob()json
' for json()text
' for text()stream
' for NodeJs.readableStream()default is 'download
'
options
Standard Request/Fetch Options for the HTTP(S) request
Returns: Promise of response body
of above type, only if status text is OK
The response type will set Fetch/Request header 'Content-Type'
as:
json
' = 'application/json; charset=utf-8'text
' = 'application/x-www-form-urlencoded'blob
' = 'application/octet'buffer
' = 'application/octet'header
' = 'text/plain'object
' = 'application/json; charset=utf-8'stream
' = 'application/octet'array
' = 'application/octet'fetching.get(url
, response_body_type
[, options
]);
fetching.head(url
, response_body_type
[, options
]);
fetching.options(url
, response_body_type
[, options
);]
body
dataNote:
body
data is passed in, handled by URLSearchParams class, ifString
orObject
.
fetching.post(url
, body
, response_body_type
[, options
]);
fetching.put(url
, body
, response_body_type
[, options
]);
fetching.patch(url
, body
, response_body_type
[, options
]);
fetching.delete(url
, body
, response_body_type
[, options
]);
fetching.fetch(url
[, options
]);
const fetching = require('node-wget-fetch');
fetching.wget(url) // retrieve to current directory
.then((info) => {});
.catch((error) => {});
fetching.wget(url, { headers: { Accept: '*/*' } }) // with optional `Fetch` options
.then((info) => {});
.catch((error) => {});
fetching.wget(url, destination_folder_or_filename, { timeout: 2000 } ) // with optional `Fetch` options
.then((info) => {});
.catch((error) => {});
fetching(url, responseType, // *responseType* can be:
// 'header' for all response headers - raw()
// 'object' for the response object - no post/pre processing
// 'array' for arrayBuffer()
// 'buffer' for buffer()
// 'blob' for blob()
// 'json' for json()
// 'text' for text()
// 'stream' for NodeJs.readableStream()
// default is 'download'
{ headers: {Accept: '*/*' } }) // with optional `Fetch` options
)
.then((processedResponse) => {
// No file is retrieved or saved,
// an resolved `Fetch` response body of above type is returned
});
.catch((error) => {});
const wget = require('node-wget-fetch');
wget('https://raw.github.com/techno-express/node-wget-fetch/master/angleman.png'); // angleman.png saved to current folder
wget('https://raw.github.com/techno-express/node-wget-fetch/master/package.json',
'/tmp/', // destination path or path with filename, default is ./
{ timeout: 2000 } // Any `Fetch` Options, this sets duration to wait for request in milliseconds, default 0
)
.then((info) => {
console.log('--- headers:'); // display all response headers
console.log(info.headers);
console.log('--- file path:'); // display file retrieved info
console.log(info.filepath);
console.log('--- file size retrieved:');
console.log(info.fileSize);
console.log('--- Do file retrieved match "Content-Length"?:');
console.log(info.fileSizeMatch);
})
.catch((error) => {
console.log('--- error:');
console.log(error); // error encountered
});
);
Install:
npm install -g node-wget-fetch
Use:
Usage: wget [options] <url>
Or
Usage: fetch [options] <url>
Ultra simple async retrieval of remote files over http or https
Options:
-h, --help output usage information
-v, --version output version number
-d, --destination <folder> specify download destination
Usage:
# Download file
$ wget https://github.com/NodeOS/NodeOS/archive/master.zip
$ fetch https://github.com/NodeOS/NodeOS/archive/master.zip
# Download file to location
$ wget https://github.com/NodeOS/NodeOS/archive/master.zip -d path/to/here/
$ fetch https://github.com/NodeOS/NodeOS/archive/master.zip -d path/to/here/
FAQs
Ultra simple async retrieval of resources or remote files over http or https, an cli tool, and convenience wrapper of node-fetch, and a seamless retry ability
We found that node-wget-fetch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.