{"name":"@digitalbazaar/http-client","version":"1.0.0","description":"An opinionated, isomorphic HTTP client.","license":"BSD-3-Clause","main":"index.js","scripts":{"test":"npm run test-node","test-node":"cross-env NODE_ENV=test mocha -r esm --preserve-symlinks -t 30000 -A -R ${REPORTER:-spec} --require tests/test-mocha.js tests/*.spec.js","test-karma":"karma start karma.conf.js","test-watch":"cross-env NODE_ENV=test mocha -r esm --watch --preserve-symlinks -t 30000 -A -R ${REPORTER:-spec} --require tests/test-mocha.js tests/*.spec.js","coverage":"cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary npm run test-node","coverage-ci":"cross-env NODE_ENV=test nyc --reporter=lcovonly npm run test-node","coverage-report":"nyc report","lint":"eslint ."},"dependencies":{"esm":"^3.2.22","ky":"^0.20.0","ky-universal":"^0.7.0"},"devDependencies":{"@babel/core":"^7.10.2","@babel/plugin-transform-modules-commonjs":"^7.10.1","@babel/plugin-transform-runtime":"^7.10.1","@babel/preset-env":"^7.10.2","@babel/runtime":"^7.10.2","chai":"^4.2.0","cross-env":"^7.0.2","detect-node":"^2.0.4","eslint":"^7.2.0","eslint-config-digitalbazaar":"^2.5.0","karma":"^5.0.9","karma-babel-preprocessor":"^8.0.1","karma-chai":"^0.1.0","karma-chrome-launcher":"^3.1.0","karma-mocha":"^2.0.1","karma-mocha-reporter":"^2.2.5","karma-sourcemap-loader":"^0.3.7","karma-webpack":"^4.0.2","mocha":"^7.2.0","nyc":"^15.1.0","webpack":"^4.43.0"},"repository":{"type":"git","url":"git+https://github.com/digitalbazaar/http-client.git"},"keywords":["http","isomorphic","http client"],"author":{"name":"Digital Bazaar, Inc.","email":"support@digitalbazaar.com","url":"https://digitalbazaar.com/"},"bugs":{"url":"https://github.com/digitalbazaar/http-client/issues"},"homepage":"https://github.com/digitalbazaar/http-client","module":"main.js","engines":{"node":">=10.0.0"},"nyc":{"exclude":["tests"]},"gitHead":"dde5880fb803881c8eccd398701796d7fc5d3030","_id":"@digitalbazaar/http-client@1.0.0","_nodeVersion":"14.4.0","_npmVersion":"6.14.5","dist":{"integrity":"sha512-BuaQ5DT1Fmdj178IAEOnWjgg8mmJPo5eEInS1pPOqDCItgFiUEdCR1KiR5Ey/oD+h1Zx0ozYQnP/a2Z7TCCKRg==","shasum":"babd6914597a74d5c9f5186e01fc0a9b985114be","tarball":"http://registry-npm.ywwl.com/@digitalbazaar/http-client/download/@digitalbazaar/http-client-1.0.0.tgz","fileCount":6,"unpackedSize":7486,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe65+pCRA9TVsSAnZWagAAOKQP/3wZACPmXrzC5oF3pxDS\nEdx5IkOdNSojtFTACjp/cis8jWNAUbOK28MQxnvXewH3gbjjYVAIU2DxOP/F\nx6lbcudYQvn3yJ/pDxiPTf5rfwJkW89uAj16XFaPUSd0JR2lNYNRvgADIgFX\n4k/zM43dFQ37iP0xKks0LS6GJ4aLGPg5QHxeIusBNlKcYxkWWxuO+PX5lOBH\n9CYE4beDPe05uz9fguthgrqSYpgFWoDP3Rqf02xfe1RYnVyBV8iTTI5rZvaR\nOrBi6NWgIVO5yrs0LmKYY5dMDOgNcq4NNoFLo1JxZ/ZRtbo8bbHP7CAGGRpH\ncqCswRmkAsUqcbhCI0+fXwDkBsw0MEvp7HE0JTYgH8RMVY0YVq+ItdIoaH68\nE1F0jghJbCwX16dw1evK+hNHVuswrksVfgov1HZRAFaYoq2xzrsmybars16z\nrlKRD+wssOBWqqYq3AbGaLoSRVFYfP4IOLqJ0IUNaKhldaUMoOCYNpTXz6y1\nWrYtQX4qWoZVfIN6mdP7Ov42HfIhDJmWv8ZcLCp9ZzCmmAR8DdI+qwcZlKPe\ndYCmIegQG5H0LkjHUG7HCg+2iY0hZAMyhzMryR1cD0i3LbvLLMhPOGY5tR9e\nRZ9TtLhMT0P8c4jglTtYBwYhhzDDzJxZrIOnkdMNuyROcFfg7wBbcXtfpUP0\nBo5R\r\n=6CbX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBqARneveKaig0zsLIgIhpgXbhZEgUpA/uMTqGPGKJlwAiEAq01zUhgVwLQbZrJ+vVYfr0Sn/cYzkc/hTzXTqIMbXTU="}],"size":3190,"noattachment":false,"key":"/@digitalbazaar/http-client/-/@digitalbazaar/http-client-1.0.0.tgz"},"maintainers":[{"name":"dlongley","email":"dlongley@digitalbazaar.com"},{"name":"msporny","email":"msporny@digitalbazaar.com"},{"name":"davidlehn","email":"dil@lehn.org"},{"name":"mattcollier","email":"mcollier@digitalbazaar.com"}],"_npmUser":{"name":"mattcollier","email":"mcollier@digitalbazaar.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/http-client_1.0.0_1592500137417_0.40959933176721264"},"_hasShrinkwrap":false,"readme":"# http-client\nAn opinionated, isomorphic HTTP client for Node.js, browsers, and React Native.\n\n### Usage\n\n#### Import httpClient (Node.js)\n```js\nimport https from 'https';\nimport {httpClient} from '@digitalbazaar/http-client';\n```\n\n#### Import httpClient (browsers or React Native)\n```js\nimport {httpClient} from '@digitalbazaar/http-client';\n```\n\n#### Import and initialize a custom Bearer Token client\n```js\nimport {httpClient} from '@digitalbazaar/http-client';\n\nconst httpsAgent = new https.Agent({rejectUnauthorized: false});\n\nconst accessToken = '12345';\nconst headers = {Authorization: `Bearer ${accessToken}`};\n\nconst client = httpClient.extend({headers, httpsAgent});\n\n// subsequent http calls will include an 'Authorization: Bearer 12345' header,\n// and use the provided httpsAgent\n```\n\n#### GET a JSON response in the browser\n```js\ntry {\n  const response = await httpClient.get('http://httpbin.org/json');\n  return response.data;\n} catch(e) {\n  // status is HTTP status code\n  // data is JSON error from the server\n  const {data, status} = e;\n  throw e;\n}\n```\n\n#### GET a JSON response in Node with an HTTP Agent\n```js\nimport https from 'https';\n// use an agent to avoid self-signed certificate errors\nconst agent = new https.Agent({rejectUnauthorized: false});\ntry {\n  const response = await httpClient.get('http://httpbin.org/json', {agent});\n  return response.data;\n} catch(e) {\n  // status is HTTP status code\n  // data is JSON error from the server if available\n  const {data, status} = e;\n  throw e;\n}\n```\n\n#### GET HTML by overriding default headers\n```js\nconst headers = {Accept: 'text/html'};\ntry {\n  const response = await httpClient.get('http://httpbin.org/html', {headers});\n  // see: https://developer.mozilla.org/en-US/docs/Web/API/Response#methods\n  return response.text();\n} catch(e) {\n  // status is HTTP status code\n  // any message from the server can be parsed from the response if present\n  const {response, status} = e;\n  throw e;\n}\n```\n\n#### POST a JSON payload\n```js\ntry {\n  const response = await httpClient.post('http://httpbin.org/json', {\n    // `json` is the payload or body of the POST request\n    json: {some: 'data'}\n  });\n  return response.data;\n} catch(e) {\n  // status is HTTP status code\n  // data is JSON error from the server\n  const {data, status} = e;\n  throw e;\n}\n```\n\n#### POST a JSON payload in Node with an HTTP Agent\n```js\nimport https from 'https';\n// use an agent to avoid self-signed certificate errors\nconst agent = new https.Agent({rejectUnauthorized: false});\ntry {\n  const response = await httpClient.post('http://httpbin.org/json', {\n    agent,\n    // `json` is the payload or body of the POST request\n    json: {some: 'data'}\n  });\n  return response.data;\n} catch(e) {\n  // status is HTTP status code\n  // data is JSON error from the server\n  const {data, status} = e;\n  throw e;\n}\n```\n","publish_time":1592500137605,"_cnpm_publish_time":1592500137605,"dist-tags":{"latest":"4.4.0"}}