doc update
This commit is contained in:
parent
2e875d24b8
commit
c737ad9482
|
@ -2,6 +2,14 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
|
||||
# 1.x release
|
||||
|
||||
## v1.0.0
|
||||
|
||||
- Enhance: better test coverage and doc
|
||||
|
||||
|
||||
# 0.x release
|
||||
|
||||
## v0.1
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Known limits
|
||||
============
|
||||
|
||||
*As of 0.x release*
|
||||
*As of 1.x release*
|
||||
|
||||
- Topics such as cross-origin, content security policy, mixed content, service workers are ignored, given our server-side context.
|
||||
|
||||
|
@ -14,4 +14,6 @@ Known limits
|
|||
|
||||
- Similarly, `req.body` can either be a string or a readable stream.
|
||||
|
||||
- Only support `res.text()` and `res.json()` at the moment, until there are good use-cases for blob.
|
||||
|
||||
- There is currently no built-in caching, as server-side caching varies by use-cases.
|
||||
|
|
31
README.md
31
README.md
|
@ -25,6 +25,9 @@ Hence `node-fetch`, minimal code for a `window.fetch` compatible API on node.js
|
|||
- Stay consistent with `window.fetch` API.
|
||||
- Make conscious trade-off when following [whatwg fetch spec](https://fetch.spec.whatwg.org/) and [stream spec](https://streams.spec.whatwg.org/) implementation details, document known difference.
|
||||
- Use native promise, but allow substituting it with [insert your favorite promise library].
|
||||
- Use native stream for body, on both request and response.
|
||||
- Decode content encoding (gzip/deflate) properly, and convert string output (such as `res.text()` and `res.json()`) to utf-8 automatically.
|
||||
- Useful extensions such as timeout, redirect limit, response size limit.
|
||||
|
||||
|
||||
# Difference from client-side fetch
|
||||
|
@ -120,6 +123,34 @@ co(function *() {
|
|||
See [test cases](https://github.com/bitinn/node-fetch/blob/master/test/test.js) for more examples.
|
||||
|
||||
|
||||
# API
|
||||
|
||||
## fetch(url, options)
|
||||
|
||||
Returns a `Promise`
|
||||
|
||||
### Url
|
||||
|
||||
Should be an absolute url, eg `http://example.com/`
|
||||
|
||||
### Options
|
||||
|
||||
default values are shown, note that only `method`, `headers` and `body` are allowed in `window.fetch`, others are node.js extensions.
|
||||
|
||||
```
|
||||
{
|
||||
method: 'GET'
|
||||
, headers: {} // request header, format {a:1} or {b:[1,2,3]}
|
||||
, follow: 20 // maximum redirect count, 0 to disable
|
||||
, timeout: 0 // request timeout in ms, 0 to disable, note that it's for each request when following redirect
|
||||
, compress: true // support gzip/deflate content encoding, false to disable
|
||||
, size: 0 // maximum response body size in bytes, 0 to disable
|
||||
, body: empty // request body, can be a string or readable stream
|
||||
, agent: null // custom http.Agent instance
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
# License
|
||||
|
||||
MIT
|
||||
|
|
Loading…
Reference in New Issue