ipfs-utils
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -0,1 +1,11 @@ | ||
<a name="2.2.0"></a> | ||
# [2.2.0](https://github.com/ipfs/js-ipfs-utils/compare/v2.1.0...v2.2.0) (2020-04-14) | ||
### Features | ||
* add json option to http ([#34](https://github.com/ipfs/js-ipfs-utils/issues/34)) ([070a456](https://github.com/ipfs/js-ipfs-utils/commit/070a456)) | ||
<a name="2.1.0"></a> | ||
@@ -2,0 +12,0 @@ # [2.1.0](https://github.com/ipfs/js-ipfs-utils/compare/v2.0.0...v2.1.0) (2020-04-13) |
{ | ||
"name": "ipfs-utils", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Package to aggregate shared logic and dependencies for the IPFS ecosystem", | ||
@@ -43,3 +43,3 @@ "main": "src/index.js", | ||
"merge-options": "^2.0.0", | ||
"nanoid": "^2.1.11", | ||
"nanoid": "^3.1.3", | ||
"node-fetch": "^2.6.0", | ||
@@ -49,7 +49,4 @@ "stream-to-it": "^0.2.0" | ||
"devDependencies": { | ||
"aegir": "^21.4.2", | ||
"chai": "^4.2.0", | ||
"chai-as-promised": "^7.1.1", | ||
"aegir": "^21.8.0", | ||
"delay": "^4.3.0", | ||
"dirty-chai": "^2.0.1", | ||
"it-all": "^1.0.1", | ||
@@ -56,0 +53,0 @@ "it-drain": "^1.0.0", |
@@ -8,5 +8,7 @@ /* eslint-disable no-undef */ | ||
const TextDecoder = require('./text-encoder') | ||
const Request = require('./globalthis').Request | ||
const AbortController = require('abort-controller') | ||
const Request = fetch.Request | ||
const Headers = fetch.Headers | ||
class TimeoutError extends Error { | ||
@@ -53,2 +55,3 @@ constructor () { | ||
const defaults = { | ||
headers: {}, | ||
throwHttpErrors: true, | ||
@@ -62,2 +65,3 @@ credentials: 'same-origin', | ||
* @prop {any} [body] - Request body | ||
* @prop {Object} [json] - JSON shortcut | ||
* @prop {string} [method] - GET, POST, PUT, DELETE, etc. | ||
@@ -84,2 +88,3 @@ * @prop {string} [base] - The base URL to use in case url is a relative URL | ||
this.opts = merge(defaults, options) | ||
this.opts.headers = new Headers(options.headers) | ||
@@ -108,2 +113,3 @@ // connect internal abort to external | ||
const opts = merge(this.opts, options) | ||
opts.headers = new Headers(opts.headers) | ||
@@ -135,2 +141,7 @@ // validate resource type | ||
if (opts.json !== undefined) { | ||
opts.body = JSON.stringify(opts.json) | ||
opts.headers.set('content-type', 'application/json') | ||
} | ||
const response = await timeout(fetch(url, opts), opts.timeout, this.abortController) | ||
@@ -137,0 +148,0 @@ |
'use strict' | ||
const nanoid = require('nanoid') | ||
const { nanoid } = require('nanoid') | ||
@@ -5,0 +5,0 @@ /** |
@@ -6,3 +6,3 @@ 'use strict' | ||
const path = require('path') | ||
const nanoid = require('nanoid') | ||
const { nanoid } = require('nanoid') | ||
@@ -9,0 +9,0 @@ /** |
55413
6
931
3
+ Addednanoid@3.3.7(transitive)
- Removednanoid@2.1.11(transitive)
Updatednanoid@^3.1.3