UNPKG

1.93 kBMarkdownView Raw
1[![npm][download-badge]][npm]
2[![David][dep-badge]][dep-link]
3[![Coverage Status][coverage-badge]][coverage-link]
4[![Build Status][build-badge]][build-link]
5
6[![NPM][large-badge]][stats-link]
7
8# snekfetch <sup>[![Version Badge][version-badge]][npm]</sup>
9
10Snekfetch is a fast, efficient, and user-friendly library for making HTTP requests.
11
12It also supports native ALPN negotiation in node for efficient http/2 requests!
13
14The API was inspired by superagent, however it is much smaller and faster.
15In fact, in browser, it is a mere 4.0kb.
16
17Documentation is available at https://snekfetch.js.org/
18
19## Some examples
20
21```javascript
22const request = require('snekfetch');
23
24request.post('https://httpbin.org/post')
25 .send({ usingGoodRequestLibrary: true })
26 .then(r => console.log(r.body)); // r.body is object from json response
27
28request.get('https://s.gc.gy/o-SNAKES.jpg')
29 .then(r => fs.writeFile('download.jpg', r.body)); // r.body is buffer
30
31request.get('https://s.gc.gy/o-SNAKES.jpg')
32 .pipe(fs.createWriteStream('download.jpg')); // pipes
33```
34
35Available for browser as UMD from [unpkg][unpkg-link]
36```html
37<script src="https://unpkg.com/snekfetch"></script>
38```
39
40[npm]: https://npmjs.org/package/snekfetch
41[large-badge]: https://nodei.co/npm/snekfetch.png?downloads=true&downloadRank=true&stars=true
42[stats-link]: https://nodei.co/npm/snekfetch/
43[version-badge]: https://versionbadge.now.sh/npm/snekfetch.svg
44[download-badge]: https://img.shields.io/npm/dt/snekfetch.svg?maxAge=3600
45[build-badge]: https://api.travis-ci.com/devsnek/snekfetch.svg?branch=master
46[build-link]: https://travis-ci.com/devsnek/snekfetch
47[dep-badge]: https://david-dm.org/devsnek/snekfetch.svg
48[dep-link]: https://david-dm.org/devsnek/snekfetch
49[coverage-badge]: https://coveralls.io/repos/github/devsnek/snekfetch/badge.svg?branch=master
50[coverage-link]: https://coveralls.io/github/devsnek/snekfetch?branch=master
51[unpkg-link]: https://unpkg.com/