node-wget-fetch
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "node-wget-fetch", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Ultra simple async retrieval of resources or remote files over http or https, an cli tool, and convenience wrapper of node-fetch.", | ||
@@ -53,4 +53,4 @@ "main": "wget-fetch.js", | ||
"mocha": "^7.2.0", | ||
"should": "~13.2.1" | ||
"should": "~13.2.3" | ||
} | ||
} |
@@ -50,21 +50,23 @@ # node-wget-fetch | ||
**fetching.get**(`url`, *action* = `response_body_type` | `options` [, `options`]) | ||
**fetching.get**(`url`, `response_body_type` [, `options`]); | ||
**fetching.head**(`url`, *action* = `response_body_type` | `options` [, `options`]) | ||
**fetching.head**(`url`, `response_body_type` [, `options`]); | ||
**fetching.options**(`url`, *action* = `response_body_type` | `options` [, `options`]) | ||
**fetching.options**(`url`, `response_body_type` [, `options`);] | ||
### For simply submitting `body` data | ||
**fetching.post**(`url`, `body`, *action* = `response_body_type` | `options` [, `options`]) | ||
> Note: `body` data is passed in, handled by **URLSearchParams** _class_, if `String` or `Object`. | ||
**fetching.put**(`url`, `body`, *action* = `response_body_type` | `options` [, `options`]) | ||
**fetching.post**(`url`, `body`, `response_body_type` [, `options`]); | ||
**fetching.patch**(`url`, `body`, *action* = `response_body_type` | `options` [, `options`]) | ||
**fetching.put**(`url`, `body`, `response_body_type` [, `options`]); | ||
**fetching.delete**(`url`, `body`, *action* = `response_body_type` | `options` [, `options`]) | ||
**fetching.patch**(`url`, `body`, `response_body_type` [, `options`]); | ||
**fetching.delete**(`url`, `body`, `response_body_type` [, `options`]); | ||
## Bring in or access [node-fetch](https://www.npmjs.com/package/node-fetch) directly | ||
**fetching.fetch**(`url` [, `options`]) | ||
**fetching.fetch**(`url` [, `options`]); | ||
@@ -71,0 +73,0 @@ ## Usage |
@@ -266,3 +266,4 @@ 'use strict'; | ||
* @param url - URL string. | ||
* @param body - Data to send. | ||
* @param body - Data to send | ||
* - Note: `body` data is passed in, handled by **URLSearchParams** _class_, if `String` or `Object`. | ||
* @param responseType Response action type: | ||
@@ -284,8 +285,12 @@ - 'header' for all response headers - raw() | ||
return function (uri, body = null, responseType = 'text', options = {}) { | ||
let params = { headers: { 'Content-Type': null}}; | ||
params = Object.assign(params, options); | ||
let params = { | ||
headers: { | ||
'Content-Type': null | ||
} | ||
}; | ||
params.method = method; | ||
params.action = responseType; | ||
params.headers['Content-Type'] = content_types[responseType] || 'application/x-www-form-urlencoded'; | ||
params.body = body; | ||
params.body = ((isString(body) && body.includes('=')) || (isObject(body))) ? new URLSearchParams(body) : body; | ||
params = Object.assign(params, options); | ||
return fetching(uri, params); | ||
@@ -416,2 +421,3 @@ } | ||
* @param body - Data to send. | ||
* - Note: `body` data is passed in, handled by **URLSearchParams** _class_, if `String` or `Object`. | ||
* @param responseType Response action type: | ||
@@ -437,2 +443,3 @@ - 'header' for all response headers - raw() | ||
* @param body - Data to send. | ||
* - Note: `body` data is passed in, handled by **URLSearchParams** _class_, if `String` or `Object`. | ||
* @param responseType Response action type: | ||
@@ -458,2 +465,3 @@ - 'header' for all response headers - raw() | ||
* @param body - Data to send. | ||
* - Note: `body` data is passed in, handled by **URLSearchParams** _class_, if `String` or `Object`. | ||
* @param responseType Response action type: | ||
@@ -479,2 +487,3 @@ - 'header' for all response headers - raw() | ||
* @param body - Data to send. | ||
* - Note: `body` data is passed in, handled by **URLSearchParams** _class_, if `String` or `Object`. | ||
* @param responseType Response action type: | ||
@@ -500,2 +509,3 @@ - 'header' for all response headers - raw() | ||
* @param body - Data to send. | ||
* - Note: `body` data is passed in, handled by **URLSearchParams** _class_, if `String` or `Object`. | ||
* @param responseType Response action type: | ||
@@ -502,0 +512,0 @@ - 'header' for all response headers - raw() |
28254
592
184