Heel
Efficient promise-based HTTP request library.
Features
- Lightweight (no dependencies)
- Easy to use
- Full Promises support
- Auto handle compressed responses (gzip, deflate)
- Auto parse response body (json)
- Auto detect and set content type
Install
npm install heel
You will need git
installed and added to PATH
for github installs
Examples
Basic Get (json)
const heel = ; ;
Headers
Querystrings
;
Post Requests
heel ;
Similar way is possible with other methods heel.[get|post|put|patch|delete]
with get being default if no method specified
Async/Await
async const res = await ; console; ;
Instances
Instances are powerful way to do many requests with lot of options instead of duplicating code
const heel = ; const api = heel; ;
Status Codes
By default the library rejects the promise on 4xx
and 5xx
Errors but it is possible to override that behavior and validate status yourself using req.status()
status s < 500 ;
As always all chainable methods are also available on instances to reduce duplications or even override the global instance
const heel = ; heelstatus s < 500; ; const api = heel status s < 500; ;