{"_id":"@colyseus/httpie","_rev":"2-b1a43ea4033a0ad1d0c7f8ffa76abf07","name":"@colyseus/httpie","dist-tags":{"latest":"2.0.1"},"versions":{"2.0.0":{"name":"@colyseus/httpie","version":"2.0.0","keywords":["http","fetch","client","request","universal","promise","xhr"],"author":{"url":"https://lukeed.com","name":"Luke Edwards","email":"luke.edwards05@gmail.com"},"license":"MIT","_id":"@colyseus/httpie@2.0.0","maintainers":[{"name":"endel","email":"endel.dreyer@gmail.com"}],"homepage":"https://github.com/lukeed/httpie#readme","bugs":{"url":"https://github.com/lukeed/httpie/issues"},"dist":{"shasum":"93a72d0e744157cd32088ab36689fcd4a1ee7956","tarball":"https://registry.npmjs.org/@colyseus/httpie/-/httpie-2.0.0.tgz","fileCount":16,"integrity":"sha512-Ksuh5CvRthqgsQE6COD7FnIFn0i8o256lej9kSJ13SHKCUfklSr+cJrBVFYn2mM2UZ96Q7qZxojUdhzxZC1SDw==","signatures":[{"sig":"MEUCIQCiWRwUtd2QcHCL0br5brc/CeT6Vbu5yh5Y6h8YvSLWKgIgPHdjfebv4cveJj4up0ZBis7JiJUFJ3HWIvTJsB7F9Bk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":28541},"main":"node/index.js","modes":{"xhr":"src/xhr.js","node":"src/node.js","fetch":"src/fetch.js"},"types":"index.d.ts","unpkg":"xhr/index.min.js","module":"node/index.mjs","worker":"fetch/index.mjs","browser":"xhr/index.mjs","engines":{"node":">=10"},"exports":{".":{"import":"./node/index.mjs","worker":"./fetch/index.mjs","browser":"./xhr/index.mjs","require":"./node/index.js"},"./xhr":{"import":"./xhr/index.mjs","require":"./xhr/index.js"},"./node":{"import":"./node/index.mjs","require":"./node/index.js"},"./fetch":{"import":"./fetch/index.mjs","require":"./fetch/index.js"},"./browser":{"import":"./xhr/index.mjs","require":"./xhr/index.js"},"./package.json":"./package.json"},"gitHead":"e869000af5b5cbd28ea0b653b71b3ed4b809429c","scripts":{"test":"uvu -r esm test","build":"bundt --main --module --unpkg","pretest":"npm run build"},"_npmUser":{"name":"endel","email":"endel.dreyer@gmail.com"},"repository":{"url":"git+https://github.com/lukeed/httpie.git","type":"git"},"_npmVersion":"9.5.1","description":"A lightweight, Promise-based HTTP client for Node.js and the browser~!","directories":{},"_nodeVersion":"18.16.0","_hasShrinkwrap":false,"devDependencies":{"esm":"3.2.25","uvu":"0.5.6","bundt":"1.1.5"},"_npmOperationalInternal":{"tmp":"tmp/httpie_2.0.0_1748638849051_0.013293349877835814","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"@colyseus/httpie","version":"2.0.1","repository":{"type":"git","url":"git+https://github.com/lukeed/httpie.git"},"description":"A lightweight, Promise-based HTTP client for Node.js and the browser~!","browser":"xhr/index.mjs","unpkg":"xhr/index.min.js","worker":"fetch/index.mjs","module":"node/index.mjs","main":"node/index.js","types":"index.d.ts","license":"MIT","exports":{".":{"types":"./index.d.ts","worker":"./fetch/index.mjs","browser":"./xhr/index.mjs","import":"./node/index.mjs","require":"./node/index.js"},"./node":{"types":"./node/index.d.ts","import":"./node/index.mjs","require":"./node/index.js"},"./fetch":{"types":"./fetch/index.d.ts","import":"./fetch/index.mjs","require":"./fetch/index.js"},"./browser":{"types":"./xhr/index.d.ts","import":"./xhr/index.mjs","require":"./xhr/index.js"},"./xhr":{"types":"./xhr/index.d.ts","import":"./xhr/index.mjs","require":"./xhr/index.js"},"./package.json":"./package.json"},"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"engines":{"node":">=10"},"scripts":{"pretest":"npm run build","build":"bundt --main --module --unpkg","test":"uvu -r esm test"},"modes":{"fetch":"src/fetch.js","node":"src/node.js","xhr":"src/xhr.js"},"keywords":["http","fetch","client","request","universal","promise","xhr"],"devDependencies":{"bundt":"1.1.5","esm":"3.2.25","uvu":"0.5.6"},"_id":"@colyseus/httpie@2.0.1","gitHead":"18bc97ceef1950f767b4fd44c8603a1462ea7633","bugs":{"url":"https://github.com/lukeed/httpie/issues"},"homepage":"https://github.com/lukeed/httpie#readme","_nodeVersion":"20.17.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-JvABMZzPLiyrUsVj3ElXGORRDTu+NKzXHWd1uV1R1SThAKMm06cVW6bOyADARD65bs8JJoHNNbUkW8KoRvRDzA==","shasum":"00a5e39f36e2a693b208bc155d08971ba6b9e467","tarball":"https://registry.npmjs.org/@colyseus/httpie/-/httpie-2.0.1.tgz","fileCount":16,"unpackedSize":28754,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDhLQuXgH7TjcYT7C4fRmUIX6vyHyQnrbGdbF/+Wcv5pgIhALExz96bY78psh8tVnv53Saql/05lFR7BJi6nJ4UW3C2"}]},"_npmUser":{"name":"endel","email":"endel.dreyer@gmail.com"},"directories":{},"maintainers":[{"name":"endel","email":"endel.dreyer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/httpie_2.0.1_1748645749538_0.8702806878400835"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-30T21:00:48.916Z","modified":"2025-05-30T22:55:49.916Z","2.0.0":"2025-05-30T21:00:49.265Z","2.0.1":"2025-05-30T22:55:49.730Z"},"bugs":{"url":"https://github.com/lukeed/httpie/issues"},"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"license":"MIT","homepage":"https://github.com/lukeed/httpie#readme","keywords":["http","fetch","client","request","universal","promise","xhr"],"repository":{"type":"git","url":"git+https://github.com/lukeed/httpie.git"},"description":"A lightweight, Promise-based HTTP client for Node.js and the browser~!","maintainers":[{"name":"endel","email":"endel.dreyer@gmail.com"}],"readme":"<div align=\"center\">\n  <img src=\"logo.png\" alt=\"httpie\" height=\"190\" />\n</div>\n\n<div align=\"center\">\n  <a href=\"https://npmjs.org/package/httpie\">\n    <img src=\"https://badgen.now.sh/npm/v/httpie\" alt=\"version\" />\n  </a>\n  <a href=\"https://travis-ci.org/lukeed/httpie\">\n    <img src=\"https://github.com/lukeed/httpie/workflows/CI/badge.svg\" alt=\"CI\" />\n  </a>\n  <a href=\"https://licenses.dev/npm/httpie\">\n    <img src=\"https://licenses.dev/b/npm/httpie\" alt=\"licenses\" />\n  </a>\n  <a href=\"https://npmjs.org/package/httpie\">\n    <img src=\"https://badgen.now.sh/npm/dm/httpie\" alt=\"downloads\" />\n  </a>\n  <a href=\"https://codecov.io/gh/lukeed/httpie\">\n    <img src=\"https://badgen.now.sh/codecov/c/github/lukeed/httpie\" alt=\"codecov\" />\n  </a>\n</div>\n\n<div align=\"center\">A Node.js and browser HTTP client as easy as pie!</div>\n\n## Features\n\n* `Promise`- based HTTP requestor\n* Works with HTTP and HTTPS protocols\n* Automatically handles JSON requests and responses\n* Extremely lightweight with **no dependencies** 678 bytes!\n* Includes aliases for common HTTP verbs: `get`, `post`, `put`, `patch`, and `del`\n\nAdditionally, this module is delivered as:\n\n* **ES Module**: [`dist/httpie.mjs`](https://unpkg.com/httpie/dist/httpie.mjs)\n* **CommonJS**: [`dist/httpie.js`](https://unpkg.com/httpie/dist/httpie.js)\n\n\n## Install\n\n```\n$ npm install --save httpie\n```\n\n\n## Usage\n\n> **Note:** The `async` syntax is for demo purposes – you may use Promises in a Node 6.x environment too!\n\n```js\nimport { get, post } from 'httpie';\n\ntry {\n  const { data } = await get('https://pokeapi.co/api/v2/pokemon/1');\n\n  // Demo: Endpoint will echo what we've sent\n  const res = await post('https://jsonplaceholder.typicode.com/posts', {\n    body: {\n      id: data.id,\n      name: data.name,\n      number: data.order,\n      moves: data.moves.slice(0, 6)\n    }\n  });\n\n  console.log(res.statusCode); //=> 201\n  console.log(res.data); //=> { id: 1, name: 'bulbasaur', number: 1, moves: [{...}, {...}] }\n} catch (err) {\n  console.error('Error!', err.statusCode, err.message);\n  console.error('~> headers:', err.headers);\n  console.error('~> data:', err.data);\n}\n```\n\n\n## API\n\n### send(method, url, opts={})\nReturns: `Promise`\n\nAny `httpie.send` request (and its aliases) will always return a Promise.\n\nIf the response's `statusCode` is 400 or above, this Promise will reject with a formatted error – see [Error Handling](#error-handling). Otherwise, the Promise will resolve with the full [`ClientRequest`](https://nodejs.org/api/http.html#http_class_http_clientrequest) stream.\n\nThe resolved response will receive a new `data` key, which will contain the response's full payload. Should the response return JSON content, then `httpie` will parse it and the `res.data` value will be the resulting JSON object!\n\n#### method\nType: `String`\n\nThe HTTP method name – it must be uppercase!\n\n#### url\nType: `String` or [`URL`](https://nodejs.org/api/url.html#url_the_whatwg_url_api)\n\nIf `url` is a string, it is automatically parsed with [`url.parse()`](https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost) into an object.\n\n#### opts.body\nType: `Mixed`<br>\nDefault: `undefined`\n\nThe request's body, can be of any type!\n\nAny non-`Buffer` objects will be converted into a JSON string and the appropriate [`Content-Type`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) header will be attached.\n\nAdditionally, `httpie` will _always_ set a value for the [`Content-Length`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Length) header!\n\n#### opts.headers\nType: `Object`<br>\nDefault: `{}`\n\nThe custom headers to send with your request.\n\n#### opts.redirect\nType: `Boolean`<br>\nDefault: `true`\n\nWhether or not redirect responses should be followed automatically.\n\n> **Note:** This may only happen with a 3xx status _and_ if the response had a [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location) header.\n\n#### opts.reviver\nType: `Function`<br>\nDefault: `undefined`\n\nAn optional function that's passed directly to [`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Parameters), allowing you transform aspects of the response data before the `httpie` request resolves.\n\n> **Note:** This will _only_ run if `httpie` detects that JSON is contained in the response!\n\n#### opts.timeout\nType: `Integer`<br>\nDefault: `undefined`\n\nThe time, in milliseconds, before automatically terminating the request.\n\nWhen the request exceeds this limit, `httpie` rejects with an `err<Error>`, adding a truthy `err.timeout` value.\n\n> **Important:** There is a slight behavioral difference between the Node & browser versions!<br>\nIn the server, the `timeout` value _does not propagate_ to any redirects.<br>\nIn the browser, the `timeout` value _will not_ reset during redirects.\n\n#### opts.withCredentials\nType: `Boolean`<br>\nDefault: `false`\n\nWhether or not cross-site requests should include credentials (such as cookies).<br>\nThis value is passed directly to [`XMLHttpRequest.withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials).\n\n**Important**: This is for the **browser version** only!\n\n\n\n### get(url, opts={})\n> Alias for [`send('GET', url, opts)`](#sendmethod-url-opts).\n\n### post(url, opts={})\n> Alias for [`send('POST', url, opts)`](#sendmethod-url-opts).\n\n### put(url, opts={})\n> Alias for [`send('PUT', url, opts)`](#sendmethod-url-opts).\n\n### patch(url, opts={})\n> Alias for [`send('PATCH', url, opts)`](#sendmethod-url-opts).\n\n### del(url, opts={})\n> Alias for [`send('DELETE', url, opts)`](#sendmethod-url-opts).\n\n\n## Error Handling\n\nAll responses with `statusCode >= 400` will result in a rejected `httpie` request. When this occurs, an Error instance is formatted with complete information:\n\n* `err.message` – `String` – Identical to `err.statusMessage`;\n* `err.statusMessage` – `String` – The response's `statusMessage` value;\n* `err.statusCode` – `Number` – The response's `statusCode` value;\n* `err.headers` – `Object` – The response's `headers` object;\n* `err.data` – `Mixed` – The response's payload;\n\nAdditionally, errors that are a result of a timeout expiration will have a truthy `err.timeout` value.\n\n> **Important:** The error's `data` property may also be parsed to a JSON object, according to the response's headers.\n\n```js\nimport { get } from 'httpie';\n\nget('https://example.com/404').catch(err => {\n  console.error(`(${err.statusCode}) ${err.message}`)\n  console.error(err.headers['content-type']);\n  console.error(`~> ${err.data}`);\n});\n//=> \"(404) Not Found\"\n//=> \"text/html; charset=UTF-8\"\n//=> ~> <?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\\n<!DOCTYPE html ...</body>\\n</html>\n```\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","readmeFilename":"readme.md"}