UNPKG

1.22 kBMarkdownView Raw
1# teeny-request
2
3Like `request`, but much smaller - and with less options. Uses `node-fetch` under the hood.
4Pop it in where you would use `request`. Improves load and parse time of modules.
5
6```ts
7import {teenyRequest as request} from 'teeny-request';
8
9request({uri: 'http://ip.jsontest.com/'}, function (error, response, body) {
10 console.log('error:', error); // Print the error if one occurred
11 console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
12 console.log('body:', body); // Print the JSON.
13});
14```
15
16## teenyRequest(options, callback)
17
18Options are limited to the following
19
20* uri
21* method, default GET
22* headers
23* json
24* qs
25* useQuerystring
26
27```ts
28request({uri:'http://service.com/upload', method:'POST', json: {key:'value'}}, function(err,httpResponse,body){ /* ... */ })
29```
30
31The callback argument gets 3 arguments:
32
33 * An error when applicable (usually from http.ClientRequest object)
34 * An response object with statusCode, a statusMessage, and a body
35 * The third is the response body (JSON object)
36
37
38
39## Thanks
40Special thanks to [billyjacobson](https://github.com/billyjacobson) for suggesting the name. Please report all bugs to them.
\No newline at end of file