{"id":13646902,"url":"https://github.com/Kong/unirest-nodejs","last_synced_at":"2025-04-21T21:31:45.454Z","repository":{"id":11260876,"uuid":"13663191","full_name":"Kong/unirest-nodejs","owner":"Kong","description":"Unirest in Node.js: Simplified, lightweight HTTP client library.","archived":false,"fork":false,"pushed_at":"2023-05-11T16:08:32.000Z","size":325,"stargazers_count":950,"open_issues_count":43,"forks_count":170,"subscribers_count":41,"default_branch":"master","last_synced_at":"2024-04-15T03:18:30.397Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://unirest.io/nodejs","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kong.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2013-10-17T22:44:16.000Z","updated_at":"2024-04-12T22:36:04.000Z","dependencies_parsed_at":"2024-01-03T05:49:05.208Z","dependency_job_id":"3aa306fd-de5b-4474-843e-6b151fb88d5e","html_url":"https://github.com/Kong/unirest-nodejs","commit_stats":{"total_commits":182,"total_committers":31,"mean_commits":5.870967741935484,"dds":0.3131868131868132,"last_synced_commit":"a06ba4e6c58fea028d377c170cb4cbf7cf3c6049"},"previous_names":["mashape/unirest-nodejs"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kong%2Funirest-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kong%2Funirest-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kong%2Funirest-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kong%2Funirest-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kong","download_url":"https://codeload.github.com/Kong/unirest-nodejs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223842585,"owners_count":17212422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:03:14.512Z","updated_at":"2025-04-21T21:31:45.434Z","avatar_url":"https://github.com/Kong.png","language":"JavaScript","readme":"# Unirest for Node.js [![Build Status][travis-image]][travis-url] \n\n[![License][npm-license]][license-url]\n[![Downloads][npm-downloads]][npm-url]\n[![Gitter][gitter-image]][gitter-url]\n[![Not Maintained](https://img.shields.io/badge/Maintenance%20Level-Not%20Maintained-yellow.svg)](https://gist.github.com/cheerfulstoic/d107229326a01ff0f333a1d3476e068d)\n\n\n![][unirest-logo]\n\n\n[Unirest](http://unirest.io) is a set of lightweight HTTP libraries available in multiple languages.\n\n## Installing\n\nTo utilize unirest for node.js install the the `npm` module:\n\n```bash\n$ npm install unirest\n```\n\nAfter installing the `npm` package you can now start simplifying requests like so:\n\n```js\nvar unirest = require('unirest');\n```\n\n## Creating Requests\n\nYou're probably wondering how by using **Unirest** makes creating requests easier. Besides automatically supporting gzip, and parsing responses, lets start with a basic working example:\n\n```js\nunirest\n  .post('http://mockbin.com/request')\n  .headers({'Accept': 'application/json', 'Content-Type': 'application/json'})\n  .send({ \"parameter\": 23, \"foo\": \"bar\" })\n  .then((response) =\u003e {\n    console.log(response.body)\n  })\n```\n\n## Uploading Files\n\nTransferring file data has been simplified:\n\n```js\nunirest\n  .post('http://mockbin.com/request')\n  .headers({'Content-Type': 'multipart/form-data'})\n  .field('parameter', 'value') // Form field\n  .attach('file', '/tmp/file') // Attachment\n  .then(function (response) {\n    console.log(response.body)\n  })\n```\n\n## Custom Entity Body\n\n```js\nunirest\n  .post('http://mockbin.com/request')\n  .headers({'Accept': 'application/json'})\n  .send(Buffer.from([1,2,3]))\n  .then(function (response) {\n    console.log(response.body)\n  })\n```\n\n# Unirest\n\nA request can be initiated by invoking the appropriate method on the unirest object, then calling `.end()` to send the request. Alternatively you can send the request directly by providing a callback along with the url.\n\n## unirest(method [, uri, headers, body, callback])\n\n- `method` - Request type (GET, PUT, POST, etc...)\n- `uri` - _Optional_; When passed will return a [Request](#request) object. Otherwise returns generated function with `method` pre-defined (e.g. `unirest.get`)\n- `headers` (`Object`) - _Optional_; HTTP Request headers\n- `body` (`Mixed`) - _Optional_; HTTP Request body\n- `callback` (`Function`) - _Optional_; Invoked when Request has finalized with the argument [Response](#response)\n\n## unirest\\[method](url [, headers, body, callback])\n\n- `method` - Request type, pre-defined methods, see below.\n- `url` - Request location.\n- `headers` (`Object` | `Function`) - _Optional_; When `Object` headers are passed along to the [`Request.header`](#requestheaderobject-or-field-value) method,\n   when `Function` this argument is used as the `callback`.\n- `body` (`Mixed` | `Function`) - _Optional_; When `body` is not a `Function` it will be passed along to `Request.send()` method,\n   otherwise when a `Function` it will be used as the `callback`.\n- `callback` (`Function`) - _Optional_; Calls end with given argument, otherwise `Request` is returned.\n\nAll arguments above, with the exclusion of `url`, will accept a `Function` as the `callback`.\nWhen no `callback` is present, the [Request](#request) object will be returned.\n\n### get\n\nReturns a [Request](#request) object with the `method` option set to `GET`\n\n```js\nvar Request = unirest.get('http://mockbin.com/request')\n```\n\n### head\nReturns a [Request](#request) object with the `method` option set to `HEAD`\n\n```js\nlet Request = unirest.head('http://mockbin.com/request')\n```\n\n### put\nReturns a [Request](#request) object with the `method` option set to `PUT`\n\n```js\nlet Request = unirest.put('http://mockbin.com/request')\n```\n\n### post\nReturns a [Request](#request) object with the `method` option set to `POST`\n\n```js\nlet Request = unirest.post('http://mockbin.com/request')\n```\n\n### patch\n\nReturns a [Request](#request) object with the `method` option set to `PATCH`\n\n```js\nlet Request = unirest.patch('http://mockbin.com/request')\n```\n\n### delete\nReturns a [Request](#request) object with the `method` option set to `DELETE`\n\n```js\nlet Request = unirest.delete('http://mockbin.com/request')\n```\n\n## unirest.jar()\n\nCreates a container to store multiple cookies, i.e. a cookie jar.\n\n```js\nlet CookieJar = unirest.jar()\nCookieJar.add('key=value', '/')\n\nunirest\n  .get('http://mockbin.com/request')\n  .jar(CookieJar)\n```\n\n## unirest.cookie(String)\n\nCreates a cookie, see above for example.\n\n## unirest.request\n\n`mikeal/request` library (the underlying layer of unirest) for direct use.\n\n# Request\n\nProvides simple and easy to use methods for manipulating the request prior to being sent. This object is created when a\nUnirest Method is invoked. This object contains methods that are chainable like other libraries such as jQuery and popular\nrequest module Superagent (which this library is modeled after slightly).\n\n**Example**\n\n```js\nvar Request = unirest.post('http://mockbin.com/request');\n\nRequest\n  .header('Accept', 'application/json')\n  .end(function (response) {\n    ...\n  })\n```\n\n## Request Methods\n\nRequest Methods differ from Option Methods (See Below) in that these methods transform, or handle the data in a sugared way, where as Option Methods require a more _hands on_ approach.\n\n#### Request.auth(Object) or (user, pass, sendImmediately)\n\nAccepts either an `Object` containing `user`, `pass`, and optionally `sendImmediately`.\n\n- `user` (`String`) - Authentication Username\n- `pass` (`String`) - Authentication Password\n- `sendImmediately` (`String`) - _Optional_; Defaults to `true`; Flag to determine whether Request should send the basic authentication header along with the request. Upon being _false_, Request will retry with a _proper_ authentication header after receiving a `401` response from the server (which must contain a `WWW-Authenticate` header indicating the required authentication method)\n\n**Object**\n\n```js\nRequest.auth({\n  user: 'Nijiko',\n  pass: 'insecure',\n  sendImmediately: true\n})\n```\n\n**Arguments**\n\n```js\nRequest.auth('Nijiko', 'insecure', true)\n```\n\n#### Request.header(header[, value])\n\n**Suggested Method for setting Headers**\n\nAccepts either an `Object` containing `header-name: value` entries,\nor `field` and `value` arguments. Each entry is then stored in a two locations, one in the case-sensitive `Request.options.headers` and the other on a private `_headers` object that is case-insensitive for internal header lookup.\n\n- `field` (`String`) - Header name, such as `Accepts`\n- `value` (`String`) - Header value, such as `application/json`\n\n**Object**\n\n```js\nRequest.headers({\n  'Accept': 'application/json',\n  'User-Agent': 'Unirest Node.js'\n})\n```\n\nNote the usage of [`Request.headers`](#requestheaders) which is simply an alias to the `Request.header` method, you can also use [`Request.set`](#requestset) to set headers.\n\n**Arguments**\n\n```js\nRequest.header('Accept', 'application/json');\n```\n\n#### Request.part(Object)\n\n**Experimental**\n\nSimiliar to `Request.multipart()` except it only allows one object to be passed at a time and does the pre-processing on necessary `body` values for you.\n\nEach object is then appended to the `Request.options.multipart` array.\n\n```js\nRequest\n  .part({\n    'content-type': 'application/json',\n    body: { foo: 'bar' }\n  })\n  .part({\n    'content-type': 'text/html',\n    body: '\u003cstrong\u003eHello World!\u003c/strong\u003e'\n  })\n```\n\n#### Request.query(Object) or (String)\n\nSerializes argument passed to a querystring representation.\n\nShould `url` already contain a querystring, the representation will be appended to the `url`.\n\n```js\nunirest\n  .post('http://mockbin.com/request')\n  .query('name=nijiko')\n  .query({\n    pet: 'spot'\n  })\n  .then((response) =\u003e {\n    console.log(response.body)\n  })\n```\n\n#### Request.send(Object | String)\n\nData marshalling for HTTP request body data\n\nDetermines whether data mime-type is `form` or `json`.\nFor irregular mime-types the `.type()` method is used to infer the `content-type` header.\n\nWhen mime-type is `application/x-www-form-urlencoded` data is appended rather than overwritten.\n\n**JSON**\n\n```js\nunirest\n  .post('http://mockbin.com/request')\n  .type('json')\n  .send({\n    foo: 'bar',\n    hello: 3\n  })\n  .then((response) =\u003e {\n    console.log(response.body)\n  })\n```\n\n**FORM Encoded**\n\n```js\n// Body would be:\n// name=nijiko\u0026pet=turtle\nunirest\n  .post('http://mockbin.com/request')\n  .send('name=nijiko')\n  .send('pet=spot')\n  .then((response) =\u003e {\n    console.log(response.body)\n  })\n```\n\n**HTML / Other**\n\n```js\nunirest\n  .post('http://mockbin.com/request')\n  .set('Content-Type', 'text/html')\n  .send('\u003cstrong\u003eHello World!\u003c/strong\u003e')\n  .then((response) =\u003e {\n    console.log(response.body)\n  })\n```\n\n#### Request.type(String)\n\nSets the header `Content-Type` through either lookup for extensions (`xml`, `png`, `json`, etc...) using `mime` or using the full value such as `application/json`.\n\nUses [`Request.header`](#requestheaderobject-or-field-value) to set header value.\n\n```js\nRequest.type('application/json') // Content-Type: application/json\nRequest.type('json') // Content-Type: application/json\nRequest.type('html') // Content-Type: text/html\n…\n```\n\n## Request Form Methods\n\nThe following methods are sugar methods for attaching files, and form fields. Instead of handling files and processing them yourself Unirest can do that for you.\n\n#### Request.attach(Object) or (name, path)\n\n`Object` should consist of `name: 'path'` otherwise use `name` and `path`.\n\n- `name` (`String`) - File field name\n- `path` (`String` | `Object`) - File value, A `String` will be parsed based on its value. If `path` contains `http` or `https` Request will handle it as a `remote file`.  If `path` does not contain `http` or `https` then unirest will assume that it is the path to a local file and attempt to find it using `path.resolve`. An `Object` is directly set, so you can do pre-processing if you want without worrying about the string value.\n\n**Object**\n\n```js\nunirest\n  .post('http://mockbin.com/request')\n  .header('Accept', 'application/json')\n  .field({\n    'parameter': 'value'\n  })\n  .attach({\n    'file': 'dog.png',\n    'relative file': fs.createReadStream(path.join(__dirname, 'dog.png')),\n    'remote file': unirest.request('http://google.com/doodle.png')\n  })\n  .then((response) =\u003e {\n    console.log(response.body)\n  })\n```\n\n**Arguments**\n\n```js\nunirest\n  .post('http://mockbin.com/request')\n  .header('Accept', 'application/json')\n  .field('parameter', 'value') // Form field\n  .attach('file', 'dog.png') // Attachment\n  .attach('remote file', fs.createReadStream(path.join(__dirname, 'dog.png')))  // Same as above.\n  .attach('remote file', unirest.request('http://google.com/doodle.png'))\n  .then((response) =\u003e {\n    console.log(response.body)\n  })\n```\n\n#### Request.field(Object) or (name, value)\n\n`Object` should consist of `name: 'value'` otherwise use `name` and `value`\n\nSee `Request.attach` for usage.\n\n#### Request.stream()\n\nSets `_stream` flag to use `request` streaming instead of direct `form-data` usage.\nThis seemingly appears to only work for node servers, use streaming only if you are a hundred percent sure it will work.\nTread carefully.\n\n## Request.options\n\nThe _options_ `object` is where almost all of the request settings live. Each option method sugars to a field on this object to allow for chaining and ease of use. If\nyou have trouble with an option method and wish to directly access the _options_ object\nyou are free to do so.\n\nThis object is modeled after the `request` libraries options that are passed along through its constructor.\n\n* `url` (`String` | `Object`) - Url, or object parsed from `url.parse()`\n* `qs` (`Object`) - Object consisting of `querystring` values to append to `url` upon request.\n* `method` (`String`) - Default `GET`; HTTP Method.\n* `headers` (`Object`) - Default `{}`; HTTP Headers.\n* `body` (`String` | `Object`) - Entity body for certain requests.\n* `form` (`Object`) - Form data.\n* `auth` (`Object`) - See `Request.auth()` below.\n* `multipart` (`Object`) - _Experimental_; See documentation below.\n* `followRedirect` (`Boolean`) - Default `true`; Follow HTTP `3xx` responses as redirects.\n* `followAllRedirects` (`Boolean`) - Default `false`; Follow **Non**-GET HTTP `3xx` responses as redirects.\n* `maxRedirects` (`Number`) - Default `10`; Maximum number of redirects before aborting.\n* `encoding` (`String`) - Encoding to be used on `setEncoding` of response data.\n* `timeout` (`Number`) - Number of milliseconds to wait before aborting.\n* `proxy` (`String`) - See `Request.proxy()` below.\n* `oauth` (`Object`) - See `Request.oauth()` below.\n* `hawk` (`Object`) - See `Request.hawk()` below\n* `strictSSL` (`Boolean`) - Default `true`; See `Request.strictSSL()` below.\n* `secureProtocol` (`String`) - See `Request.secureProtocol()` below.\n* `jar` (`Boolean` | `Jar`) - See `Request.jar()` below.\n* `aws` (`Object`) - See `Request.aws()` below.\n* `httpSignature` (`Object`) - See `Request.httpSignature()` Below.\n* `localAddress` (`String`) - See `Request.localAddress()` Below.\n* `pool` (`Object`) - See `Request.pool()` Below.\n* `forever` (`Boolean`) - Default `undefined`; See `Request.forever()` Below\n\n## Request Option Methods\n\n#### Request.url(String)\n\nSets `url` location of the current request on `Request.options` to the given `String`\n\n```js\nRequest.url('http://mockbin.com/request');\n```\n\n#### Request.method(String)\n\nSets `method` value on `Request.options` to the given value.\n\n```js\nRequest.method('HEAD');\n```\n\n#### Request.form(Object)\n\nSets `form` object on `Request.options` to the given object.\n\nWhen used `body` is set to the object passed as a `querystring` representation and the `Content-Type` header to `application/x-www-form-urlencoded; charset=utf-8`\n\n```js\nRequest.form({\n  key: 'value'\n})\n```\n\n#### Request.multipart(Array)\n\n**Experimental**\n\nSets `multipart` array containing multipart-form objects on `Request.options` to be sent along with the Request.\n\nEach objects property with the exclusion of `body` is treated as a header value. Each `body` value must be pre-processed if necessary when using this method.\n\n```js\nRequest.multipart([{\n  'content-type': 'application/json',\n  body: JSON.stringify({\n    foo: 'bar'\n  })\n}, {\n  'content-type': 'text/html',\n  body: '\u003cstrong\u003eHello World!\u003c/strong\u003e'\n}])\n```\n\n#### Request.maxRedirects(Number)\n\nSets `maxRedirects`, the number of redirects the current Request will follow, on `Request.options` based on the given value.\n\n```js\nRequest.maxRedirects(6)\n```\n\n#### Request.followRedirect(Boolean)\n\nSets `followRedirect` flag on `Request.options` for whether the current Request should follow HTTP redirects based on the given value.\n\n```js\nRequest.followRedirect(true);\n```\n\n#### Request.timeout(Number)\n\nSets `timeout`, number of milliseconds Request should wait for a response before aborting, on `Request.options` based on the given value.\n\n```js\nRequest.timeout(2000)\n```\n\n#### Request.encoding(String)\n\nSets `encoding`, encoding to be used on setEncoding of response data if set to null, the body is returned as a Buffer, on `Request.options` based on given value.\n\n```js\nRequest.encoding('utf-8')\n```\n\n#### Request.strictSSL(Boolean)\n\nSets `strictSSL` flag to require that SSL certificates be valid on `Request.options` based on given value.\n\n```js\nRequest.strictSSL(true)\n```\n\n#### Request.httpSignature(Object)\n\nSets `httpSignature`\n\n#### Request.proxy(String)\n\nSets `proxy`, HTTP Proxy to be set on `Request.options` based on value.\n\n```js\nRequest.proxy('http://localproxy.com')\n```\n\n#### Request.secureProtocol(String)\n\nSets the secure protocol to use:\n\n```js\nRequest.secureProtocol('SSLv2_method')\n// or\nRequest.secureProtocol('SSLv3_client_method')\n```\n\nSee [openssl.org](https://www.openssl.org/docs/ssl/SSL_CTX_new.html) for all possible values.\n\n#### Request.aws(Object)\n\nSets `aws`, AWS Signing Credentials, on `Request.options`\n\n```js\nRequest.aws({\n  key: 'AWS_S3_KEY',\n  secret: 'AWS_S3_SECRET',\n  bucket: 'BUCKET NAME'\n})\n```\n\n#### Request.oauth(Object)\n\nSets `oauth`, list of oauth credentials, on `Request.options` based on given object.\n\n```js\nunirest\n  .get('https://api.twitter.com/oauth/request_token')\n  .oauth({\n    callback: 'http://mysite.com/callback/',\n    consumer_key: 'CONSUMER_KEY',\n    consumer_secret: 'CONSUMER_SECRET'\n  })\n  .then(response =\u003e {\n    let access_token = response.body\n\n    return unirest\n      .post('https://api.twitter.com/oauth/access_token')\n      .oauth({\n        consumer_key: 'CONSUMER_KEY',\n        consumer_secret: 'CONSUMER_SECRET',\n        token: access_token.oauth_token,\n        verifier: token: access_token.oauth_verifier\n      })\n  })\n  .then((response) =\u003e {\n    var token = response.body\n\n    return unirest\n      .get('https://api.twitter.com/1/users/show.json')\n      .oauth({\n        consumer_key: 'CONSUMER_KEY',\n        consumer_secret: 'CONSUMER_SECRET',\n        token: token.oauth_token,\n        token_secret: token.oauth_token_secret\n      })\n      .query({\n        screen_name: token.screen_name,\n        user_id: token.user_id\n      })\n  })\n  .then((response) =\u003e {\n    console.log(response.body)\n  })\n```\n\n#### Request.hawk(Object)\n\nSets `hawk` object on `Request.options` to the given object.\n\nHawk requires a field `credentials` as seen in their [documentation](https://github.com/hueniverse/hawk#usage-example), and below.\n\n```js\nRequest.hawk({\n  credentials: {\n    key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',\n    algorithm: 'sha256',\n    user: 'Steve'\n  }\n})\n```\n\n#### Request.localAddress(String)\n\nSets `localAddress`, local interface to bind for network connections, on `Request.options`\n\n```js\nRequest.localAddress('127.0.0.1')\nRequest.localAddress('1.2.3.4')\n```\n\n#### Request.jar(Boolean) or Request.jar(Jar)\n\nSets `jar`, cookie container, on `Request.options`. When set to `true` it stores cookies for future usage.\n\nSee `unirest.jar` for more information on how to use `Jar` argument.\n\n#### Request.pool(Object)\n\nSets `pool` object on `Request.options` to the given object.\n\nA maxSockets property can also be provided on the pool object to set the max number of sockets for all agents created.\n\nNote that if you are sending multiple requests in a loop and creating multiple new pool objects, maxSockets will not work as intended. To work around this, create the pool object with the maxSockets property outside of the loop.\n\n```js\npoolOption = { maxSockets: 100 }\n\nRequest.pool poolOption\n```\n\n#### Request.forever(Boolean)\n\nSets `forever` flag to use `forever-agent` module. When set to `true`,  default http agent will be replaced by `forever-agent`, which keeps socket connections alive between keep-alive requests.\n\n```js\nRequest.forever(true);\n```\n\n#### Request.then(Function callback)\n\nPromise polyfill method. Wraps `Request.end` in a Promise and will resolve or \nreject based on the result of the request.\n\n```js\nunirest\n  .get('http://mockbin.com/request')\n  .then((response) =\u003e {\n    console.log(response)\n  })\n  .catch(err =\u003e {\n    console.log(err)\n  })\n```\n\n#### Request.end(Function callback)\n\nSends HTTP Request and awaits Response finalization. Request compression and Response decompression occurs here.\nUpon HTTP Response post-processing occurs and invokes `callback` with a single argument, the `[Response](#response)` object.\n\n```js\nunirest\n  .get('http://mockbin.com/request')\n  .end((response) =\u003e {\n    console.log(response)\n  })\n```\n\n## Request Aliases\n\n#### Request.set\n\n**Alias** for [`Request.header()`](#requestheaderobject-or-field-value)\n\n#### Request.headers\n\n**Alias** for [`Request.header()`](#requestheaderobject-or-field-value)\n\n#### Request.redirects\n\n**Alias** for [`Request.maxRedirects()`](#requestmaxredirectsnumber)\n\n#### Request.redirect\n\n**Alias** for [`Request.followRedirect()`](#requestfollowredirectboolean)\n\n#### Request.ssl\n\n**Alias** for [`Request.strictSSL()`](#requeststrictsslboolean)\n\n#### Request.ip\n\n**Alias** for [`Request.localAddress()`](#requestlocaladdressstring)\n\n#### Request.complete\n\n**Alias** for [`Request.end()`](#requestlocaladdressstring)\n\n#### Request.as.json\n\n**Alias** for [`Request.end()`](#requestendfunction-callback)\n\n#### Request.as.binary\n\n**Alias** for [`Request.end()`](#requestendfunction-callback)\n\n#### Request.as.string\n\n**Alias** for [`Request.end()`](#requestendfunction-callback)\n\n# Response\n\nUpon ending a request, and receiving a Response the object that is returned contains a number of helpful properties to ease coding pains.\n\n## General\n\n\n- `body` (`Mixed`) - Processed body data\n- `raw_body` (`Mixed`) - Unprocessed body data\n- `headers` (`Object`) - Header details\n- `cookies` (`Object`) - Cookies from `set-cookies`, and `cookie` headers.\n- `httpVersion` (`String`) - Server http version. (e.g. 1.1)\n- `httpVersionMajor` (`Number`) - Major number (e.g. 1)\n- `httpVersionMinor` (`Number`) - Minor number (e.g. 1)\n- `url` (`String`) - Dependant on input, can be empty.\n- `domain` (`String` | `null`) - Dependant on input, can be empty.\n- `method` (`String` | `null`) - Method used, dependant on input.\n- `client` (`Object`) - Client Object. Detailed information regarding the Connection and Byte throughput.\n- `connection` (`Object`) - Client Object. Specific connection object, useful for events such as errors. **Advanced**\n- `socket` (`Object`) Client Object. Socket specific object and information. Most throughput is same across all three client objects.\n- `request` (`Object`) - Initial request object.\n- `setEncoding` (`Function`) - Set encoding type.\n\n## Status Information\n\n- `code` (`Number`) - Status Code, i.e. `200`\n- `status` (`Number`) - Status Code, same as above.\n- `statusType` (`Number`) - Status Code Range Type\n  - `1` - Info\n  - `2` - Ok\n  - `3` - Miscellaneous\n  - `4` - Client Error\n  - `5` - Server Error\n- `info` (`Boolean`) - Status Range Info?\n- `ok` (`Boolean`) - Status Range Ok?\n- `clientError` (`Boolean`) - Status Range Client Error?\n- `serverError` (`Boolean`) - Status Range Server Error?\n- `accepted` (`Boolean`) - Status Code `202`?\n- `noContent` (`Boolean`) - Status Code `204` or `1223`?\n- `badRequest` (`Boolean`) - Status Code `400`?\n- `unauthorized` (`Boolean`) - Status Code `401`?\n- `notAcceptable` (`Boolean`) - Status Code `406`?\n- `notFound` (`Boolean`) - Status Code `404`?\n- `forbidden` (`Boolean`) - Status Code `403`?\n- `error` (`Boolean` | `Object`) - Dependant on status code range.\n\n## response.cookie(name)\n\nSugar method for retrieving a cookie from the `response.cookies` object.\n\n\n```js\nvar CookieJar = unirest.jar();\nCookieJar.add(unirest.cookie('another cookie=23'));\n\nunirest.get('http://google.com').jar(CookieJar).end(function (response) {\n  // Except google trims the value passed :/\n  console.log(response.cookie('another cookie'));\n});\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n\n----\n\nMade with \u0026#9829; from the [Kong](https://www.konghq.com/) team\n\n[unirest-logo]: http://cl.ly/image/2P373Y090s2O/Image%202015-10-12%20at%209.48.06%20PM.png\n\n\n[license-url]: https://github.com/Kong/unirest-nodejs/blob/master/LICENSE\n\n[gitter-url]: https://gitter.im/Kong/unirest-nodejs\n[gitter-image]: https://img.shields.io/badge/Gitter-Join%20Chat-blue.svg?style=flat\n\n[travis-url]: https://travis-ci.org/Kong/unirest-nodejs\n[travis-image]: https://img.shields.io/travis/Kong/unirest-nodejs.svg?style=flat\n\n[npm-url]: https://www.npmjs.com/package/unirest\n[npm-license]: https://img.shields.io/npm/l/unirest.svg?style=flat\n[npm-version]: https://badge.fury.io/js/unirest.svg\n[npm-downloads]: https://img.shields.io/npm/dm/unirest.svg?style=flat\n\n[codeclimate-url]: https://codeclimate.com/github/Kong/unirest-nodejs\n[codeclimate-quality]: https://img.shields.io/codeclimate/github/Kong/unirest-nodejs.svg?style=flat\n[codeclimate-coverage]: https://img.shields.io/codeclimate/coverage/github/Kong/unirest-nodejs.svg?style=flat\n\n[david-url]: https://david-dm.org/Kong/unirest-nodejs\n[david-image]: https://img.shields.io/david/Kong/unirest-nodejs.svg?style=flat\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKong%2Funirest-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKong%2Funirest-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKong%2Funirest-nodejs/lists"}