{"name":"@digitalbazaar/http-client","version":"1.2.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.25.1","ky-universal":"^0.8.2"},"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":"^6.3.4","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":"^5.0.0","mocha":"^8.3.2","nyc":"^15.1.0","webpack":"^5.41.1"},"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":"d125f4d1daf7acdf0ccfcadec3b4638373c92280","_id":"@digitalbazaar/http-client@1.2.0","_nodeVersion":"14.16.0","_npmVersion":"6.14.11","_npmUser":{"name":"dlongley","email":"dlongley@digitalbazaar.com"},"dist":{"integrity":"sha512-W9KQQ5pUJcaR0I4c2HPJC0a7kRbZApIorZgPnEDwMBgj16iQzutGLrCXYaZOmxqVLVNqqlQ4aUJh+HBQZy4W6Q==","shasum":"1ea3661e77000a15bd892a294f20dc6cc5d1c93b","tarball":"http://registry-npm.ywwl.com/@digitalbazaar/http-client/download/@digitalbazaar/http-client-1.2.0.tgz","fileCount":6,"unpackedSize":8616,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg9bDlCRA9TVsSAnZWagAAu+cP/06+dJvitlAoe+rZEktS\nxKXjKJf9GRN7reDRJCDyEBnvPrrlXMT+2itTdipwOydj8DN+XRVKvm+Bn6CH\n3hwTs2c0WMB8BJ8lnWMd6CsbX5zdpYT//NqDWWsCfPp71Pd2XUWDvjTJSefQ\nYFU6BapJaaHdqgSyPB5F0A+0LwysO6jvBcVm9udsgGXnKgWodcHED6ejKcZk\n6uEBq+L2mBXsnsjQ4gGFqTwKvqrUC3gi7UtRBRGm1n2EJ9ENDTRZhL6s8VD1\neysE5IrZaBBrUfy2+PYg4j4w4xbnsPTkHfzz5al2zsIBWFQpxztw0SR1m5uO\nTw7uczoYcphJnYnKUvZhz4t/F/wrq8a3SiO8HOBMuCk9c8duXxIybN5lf5KU\nFLOknGrUKDsH2hu95UOBS79wAs5n+07s8UPsiZBjbd3NuG8YAbtgsK51AmMu\nCTRSl2u84kC7Eju7H1ert41bOzdjHBMx3YIjIaqCL6gjuNLblodmIVe2NB43\nMF3Ux4dH0T5veV/dsnh3uM0xm7gEypGNBsFQ6hh9xD4aTituPQlTR+/C409s\n3CJ/Xs3DjG1vOtf9cw65WFsOrrMT0p1BQdv7/sFPiY3qNDfsgkdFxiINFx2J\nSw1gj1MB9LAxg6DNl+PmmYcsTh9V0uHHcGxCRzl3JWViQMfBcKP1FfNLw8o6\nH0C2\r\n=Wp71\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDFUmBL5TRvaUQL5fYbL3j9dj4ny44dBdLpN25nYB/RxwIhAMk5zjTQdO+XAAx8ouKx5rG1nlYbGv1yLVjMYKw1HaLf"}],"size":3482,"noattachment":false,"key":"/@digitalbazaar/http-client/-/@digitalbazaar/http-client-1.2.0.tgz"},"directories":{},"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"},{"name":"gannan","email":"gannan@digitalbazaar.com"},{"name":"codenamedmitri","email":"dzagidulin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/http-client_1.2.0_1626714340900_0.22679311246505662"},"_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":1626714341033,"_cnpm_publish_time":1626714341033,"dist-tags":{"latest":"4.4.0"}}