The Wayback Machine - https://web.archive.org/web/20201122180937/https://github.com/terkelg/hent
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
Nov 4, 2019
Nov 4, 2019
Nov 3, 2019

readme.md

hent build status codecov

Tiny utility to fetch remote files into buffers

hent is a small, promise based, utility to download remote files into nodejs buffers. Protocol and redirects are automatically handled for you.

Features

  • Promise based
  • Supports HTTP and HTTPS protocols
  • Follow redirects
  • Dependency free

Additionally, this module is delivered as:

Install

$ npm install --save hent

Usage

import hent from 'hent';

const {buffer} = await hent('https://example.com/dog.jpeg');

// access response object
const {res, buffer} = await hent('https://example.com/cat.png');

// that's it!

API

hent(url, [opts])

Returns: Promise <Object>

The returned object has two properties: buffer and res.

  • buffer is the downloaded file as a Buffer.
  • res is the node response used to access response status, headers and data.

fyi: hent is a danish word and means fetch.

url

Type: String

URL to the resource you want to download.
Protocol is automatically detected.

opts

Type: Object

Optional options object passed to http.get. Use this to define custom headers etc.

License

MIT © Terkel Gjervig

You can’t perform that action at this time.