digest-fetch
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -35,2 +35,3 @@ const canRequire = typeof(require) == 'function' | ||
addAuth (url, options) { | ||
if (typeof(options.renew) == 'function') options = options.renew() | ||
if (!this.hasAuth) return options | ||
@@ -37,0 +38,0 @@ if (this.logger) this.logger.info(`requesting with auth carried`) |
{ | ||
"name": "digest-fetch", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "digest auth request plugin for fetch/node-fetch", | ||
@@ -5,0 +5,0 @@ "main": "digest-fetch-src.js", |
@@ -23,3 +23,6 @@ # digest-fetch | ||
const DigestFetch = require('digest-fetch') | ||
const client = DigestFetch('user', 'password', console) // console as logger, optional parameter | ||
// console as logger, optional parameter | ||
const client = DigestFetch('user', 'password', console) | ||
// do request same way as fetch or node-fetch | ||
@@ -33,2 +36,10 @@ const url = '' | ||
// pass in refresh request options function for conditions options needs be refreshed when trying again. | ||
// etc: when posting with file stream | ||
const renew = () => { body: fs.createReadStream('path-to-file') } | ||
client.fetch(url, {renew}) | ||
.then(resp=>resp.json()) | ||
.then(data=>console.log(data)) | ||
.catch(e=>console.error(e)) | ||
``` | ||
@@ -35,0 +46,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
166567
472
55