commit
c2cbd0be15
|
@ -26,6 +26,7 @@ Hence `node-fetch`, minimal code for a `window.fetch` compatible API on node.js/
|
||||||
- Use native stream for body, on both request and response.
|
- 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.
|
- 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.
|
- Useful extensions such as timeout, redirect limit, response size limit.
|
||||||
|
- Exposes `Response` and `Headers` constructors
|
||||||
|
|
||||||
|
|
||||||
# Difference from client-side fetch
|
# Difference from client-side fetch
|
||||||
|
|
2
index.js
2
index.js
|
@ -190,3 +190,5 @@ Fetch.prototype.isRedirect = function(code) {
|
||||||
|
|
||||||
// expose Promise
|
// expose Promise
|
||||||
Fetch.Promise = global.Promise;
|
Fetch.Promise = global.Promise;
|
||||||
|
Fetch.Response = Response;
|
||||||
|
Fetch.Headers = Headers;
|
||||||
|
|
|
@ -59,6 +59,11 @@ describe('node-fetch', function() {
|
||||||
fetch.Promise = old;
|
fetch.Promise = old;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should expose Headers and Response constructors', function() {
|
||||||
|
expect(fetch.Headers).to.equal(Headers);
|
||||||
|
expect(fetch.Response).to.equal(Response);
|
||||||
|
});
|
||||||
|
|
||||||
it('should reject with error if url is protocol relative', function() {
|
it('should reject with error if url is protocol relative', function() {
|
||||||
url = '//example.com/';
|
url = '//example.com/';
|
||||||
return expect(fetch(url)).to.eventually.be.rejectedWith(Error);
|
return expect(fetch(url)).to.eventually.be.rejectedWith(Error);
|
||||||
|
|
Loading…
Reference in New Issue