{"_id":"@1xtr/apiapi","_rev":"4-7425fb1f82d9225b80d0a1c8c7b6ba7f","name":"@1xtr/apiapi","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.3":{"name":"@1xtr/apiapi","version":"1.0.3","description":"Create api clients for node and browser with ease","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+https://github.com/1xtr/apiapi.git"},"keywords":["api","client","xhr","ajax","rest","fetch"],"author":{"name":"Aleksei Anisimov","email":"i@trendco.dev"},"license":"MIT","bugs":{"url":"https://github.com/1xtr/apiapi/issues"},"homepage":"https://github.com/1xtr/apiapi","dependencies":{"axios":"^0.27.2","bluebird":"^3.0.2","debug":"^4.3.4","lodash":"^4.17.21","shitty-qs":"^1.0.1"},"devDependencies":{"mocha":"^10.0.0","should":"^13.2.3","sinon":"^14.0.0"},"gitHead":"bcbe430f404f4f131c33ee762efc398015ee34d6","_id":"@1xtr/apiapi@1.0.3","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"integrity":"sha512-RrUoqUaKQYNy4wULSulLo5LHuRQXt5uCL/0BE7NgcYIAPJGqSnjnIlRJbbpCve+Yr8nabWT447feVLmxJltZag==","shasum":"8cb35ec80a87271927d3efe83d990f06aa5f5983","tarball":"https://registry.npmjs.org/@1xtr/apiapi/-/apiapi-1.0.3.tgz","fileCount":6,"unpackedSize":22789,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGdr1lC3dsf52mxv3oag6qFWBBSiPVETnDCVrC2QTVcpAiEA44TNnQDmwAHERnEtDAki1rMyAQrdVxkVkvzaEsQpJGA="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi8n3UACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrRjg//aPLEvcJ34lHwrfOQKK5EdBMp3xQlM8zZYC2NyMrEU+Fr2qfj\r\nJ5BszBxasRV3u8bd0ZWhFY63d58eFNVaa2P/ME4A+5qDapUR7CDHZxeCK4lp\r\nv5b/OG4eOb9U7kEX1MXVzUJ4lxvLW2JY6juT+J0+6lIEzXkfFimglS9bT+WY\r\n8i4PumNb3gd7JSonl1ZJ6i68KNPn9mKv1TJ0CILhsfAWLLZhtOsXiS+WmX9Z\r\n8W/Ls+XmyfMGgUfrqZM2mffD/VjO6mIRn6KDT7qYFC2QcQHKlJDykA3XY+Hm\r\n3ttjRlnEAnvpc6tjKublX0jC0/d4jE8L89snTx0uSeGPjL5kZC8ki87L8tDh\r\nQQLfa+AqcTKfwwNlcZJ6Q//4L6Gy8/5S+zVizhga/wmXhwvQ0zRmy2paGx8F\r\njzI4HhtVEtJPE114gM5wZUtsRsk4KABj44IjmMvH7UWWQx9AebvozTLtMCC5\r\ni0d/kqOAonP3RA17pnzoK8gYnvkXKwwm1JdZOqHoT5yUvIV5t7rxfS66PNLb\r\nqH4DVpeb9rYVgYBOGntNhQRUZFACTcniId7Ru/p8+9tQK9dOdoLBYbVuyusz\r\n8lKXj7nJRteXTn72C5y3DM1SXeu2dfaqX1WUnbdSbXBO+eEzrph6wRKhUMKX\r\nyixuVgW8DqeU2NpIlm25l5kmX15tEiqn3tE=\r\n=brUp\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"1xtr","email":"post.aas@gmail.com"},"directories":{},"maintainers":[{"name":"1xtr","email":"post.aas@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/apiapi_1.0.3_1660059092132_0.4506698107927458"},"_hasShrinkwrap":false},"1.1.2":{"name":"@1xtr/apiapi","version":"1.1.2","description":"Create api clients for node and browser with ease","main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"}},"scripts":{"test":"mocha","eslint":"eslint"},"repository":{"type":"git","url":"git+https://github.com/1xtr/apiapi.git"},"keywords":["api","client","xhr","ajax","rest","fetch"],"author":{"name":"Aleksei Anisimov","email":"i@trendco.dev"},"license":"MIT","bugs":{"url":"https://github.com/1xtr/apiapi/issues"},"homepage":"https://github.com/1xtr/apiapi","dependencies":{"axios":"^1.2.2","axios-rate-limit":"^1.3.0","debug":"^4.3.4","lodash":"^4.17.21","shitty-qs":"^1.0.1"},"devDependencies":{"@typescript-eslint/parser":"^5.48.1","bluebird":"^3.7.2","eslint":"^8.31.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.2.1","mocha":"^10.2.0","prettier":"^2.8.2","should":"^13.2.3","sinon":"^15.0.1","typescript":"^4.9.4"},"types":"./index.d.ts","gitHead":"cdf78b126f1382475ca7359bdce742328957231f","_id":"@1xtr/apiapi@1.1.2","_nodeVersion":"16.18.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-XIdb8pIXs23F/OLY/O1/mKn2YeyRvYT9L/tUzo9JGyagu1s6wqFf5TILkeUAh+gn5OUiFUF2m2Y8bd8v8Jkofw==","shasum":"b802e5faecfc0cf3fb7d91de6458a2419d3e4c73","tarball":"https://registry.npmjs.org/@1xtr/apiapi/-/apiapi-1.1.2.tgz","fileCount":10,"unpackedSize":35940,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQClY3puw6//SSulZ9EIl3OcaQGFD4o2SW3xgjbMlFjc0wIgQVjuG+5/Fv0P7GajNaVVq1sfg0HW7UwLut62sAH+Uuc="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjvIeVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrpXg//RfWrIQdrxSZ7a8kFgZBqCmmyxhWwwdxUaf+b7i7/ZBE/xQTr\r\nEEfKFfhOipfUnZuApys79TQNb/CZ3nlcQTMsXGFh2EitXPTY0hfioYUmNwvB\r\n0z1SQx9QWwmcMrkO9YE62iwWGvylkd/lQa9orzZHRLqb2jBK1kJ2n4LKqgD/\r\nvEPykJJZStZ9lSuiK7o3Z0fXvWhk+cx6xZwHTI0F4XEhMXACziJCcPj/pPPl\r\nWJpOEd9ErJyf0r8qmZfxzofpXK/YHBhx2mHX9lRn6l2e55NRlPshHXV9/1zm\r\nEKDwJecCKPRi0f/kFUpImAU2UnziEg84Fs+VI971fhmNyTwfijGDSzLzeu+O\r\nzqOXgm2TWR9iq6e6/muHnLzWGkDIILl4NamhwcU8AJlBDajQ5B5ZXrNym2qE\r\nnZMv78vzSIe2GcmjDQwlYucIsoMeP4YW7Td4KegJmt5ImEgaqNSu3WY2Bsp3\r\n8ocL4WgtE9vGaKfeDOPvlfsjJVHHn1/oI2PPbRwo/nT8CJFSxoqoZmvUtuLy\r\n5o1s54b2TiB7rziPgeCjzHGIEifCl9MNavLa/BDIRtD/+swu4A+faFxC625S\r\nfbHacSbb+IvJlW7zTT65qhz1tk8vC8+3KMlRE10WLz65mRC/Lc3hN5KmkXAM\r\n1C1YQw24k9iEFCJMHiqkeml77qN6d8o5WY0=\r\n=ZYyz\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"1xtr","email":"i@trendco.dev"},"directories":{},"maintainers":[{"name":"1xtr","email":"i@trendco.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/apiapi_1.1.2_1673299861771_0.1664216855429672"},"_hasShrinkwrap":false},"1.1.3":{"name":"@1xtr/apiapi","version":"1.1.3","description":"Create api clients for node and browser with ease","main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"}},"scripts":{"test":"mocha","eslint":"eslint"},"repository":{"type":"git","url":"git+https://github.com/1xtr/apiapi.git"},"keywords":["api","client","xhr","ajax","rest","fetch"],"author":{"name":"Aleksei Anisimov","email":"i@trendco.dev"},"license":"MIT","bugs":{"url":"https://github.com/1xtr/apiapi/issues"},"homepage":"https://github.com/1xtr/apiapi","dependencies":{"axios":"^1.2.2","axios-rate-limit":"^1.3.0","debug":"^4.3.4","lodash":"^4.17.21","shitty-qs":"^1.0.1"},"devDependencies":{"@typescript-eslint/parser":"^5.48.1","bluebird":"^3.7.2","eslint":"^8.31.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.2.1","mocha":"^10.2.0","prettier":"^2.8.2","should":"^13.2.3","sinon":"^15.0.1","typescript":"^4.9.4"},"gitHead":"9577ed2d2f80aa10bde6724b74f5b0bb84afbec0","_id":"@1xtr/apiapi@1.1.3","_nodeVersion":"16.18.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-LmXaf18rM4+QKfYRTLahnZ/DbQJoZj0+5EslZFWA9aNTJtLIpYKDAUElMbQ04OcoGDqf/hy7vKyoZmd07fhXpw==","shasum":"3ad97c77a594226fd7b30432a1a5320537d5e0e8","tarball":"https://registry.npmjs.org/@1xtr/apiapi/-/apiapi-1.1.3.tgz","fileCount":10,"unpackedSize":35951,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDfQhZ0OU55MoaLlzyEbanLlpkaI8YDwbnN50BIyDI0JgIgG5BXIwOFwmnMv+F81UhLCHQvP2qVXin4AVfFRVMTN8U="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjvI0xACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpKzQ//ZWDylzW30V8pOq/EnKqwsiCeqKo55Ny4DFOw3grr7+bRCJtM\r\niq2o7sIWol3Lx5Z6iR/6uwrBlvzi/3wUnhIupefmUPfxAEZ5tqnB1zaoiwQZ\r\nLBUWV4BVgHR60mrA+9mZf43786khRGRQSReTVZdf9QJa1M/+mPtCtcAh4RYe\r\nj1h/ilITd3S7JxR5tvti53IXpIi0fW1ImuERXge838Nkw8/s30mKCpizw+yU\r\nDmkhkg9WXJIrAjjH7tKA+Inwlt7lKGoOKqaOfvMdS4JIb+0O0xZjMhSAdDC7\r\nf4WLBw05klEosqO0SpFhiW4i08o5jW/vllOxZ+cltdfUXFC/F/fh+P1kAKFR\r\n3Y7P844TasCiwRLy7FHxtwrOzMA8xck/LA1wVT9l++wJ2+821EJw/TSSw0eR\r\nB2qqeYszo05G7sMFhLXOLb92IvJPcmPGHuz0RW8lXdycREuFgdK5Ej96m+eZ\r\ncgDuP63qBouoV+1fwwPOg3AW3CMqyxkkSWlG9zlHP3YZWJWL8xxvaqZI24t4\r\ngwU2ec2MfFhTw8Wv2qt+4vY0u4OnhekCWs+j+H69Jmg7tDTEQuicolu32nxn\r\nuxjDGndtOZ41Ky+Hv1UumYflb7q4FbL3IgTx/F2SFLs4LIlxJb2tH5rcgti0\r\npJCoKf8txbgRXg8soNgjbcvhelNOvRaqeUk=\r\n=ptuG\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"1xtr","email":"i@trendco.dev"},"directories":{},"maintainers":[{"name":"1xtr","email":"i@trendco.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/apiapi_1.1.3_1673301297493_0.29822469177143685"},"_hasShrinkwrap":false},"2.0.0":{"name":"@1xtr/apiapi","version":"2.0.0","description":"Create api clients for node and browser with ease","main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"}},"scripts":{"test":"mocha","eslint":"eslint"},"repository":{"type":"git","url":"git+https://github.com/1xtr/apiapi.git"},"keywords":["api","client","xhr","ajax","rest","fetch"],"author":{"name":"Aleksei Anisimov","email":"i@1xtr.dev"},"license":"MIT","bugs":{"url":"https://github.com/1xtr/apiapi/issues"},"homepage":"https://github.com/1xtr/apiapi","dependencies":{"axios":"^1.6.7","axios-rate-limit":"1.3.0","debug":"4.3.4","http-build-query":"^0.7.0","lodash":"4.17.21","shitty-qs":"1.0.1"},"devDependencies":{"@typescript-eslint/parser":"^5.48.1","bluebird":"^3.7.2","eslint":"^8.31.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.2.1","mocha":"^10.2.0","prettier":"^2.8.2","should":"^13.2.3","sinon":"^15.0.1","typescript":"^4.9.4"},"gitHead":"fbab8b00af7cd537848a0e4a58f7161231e903e1","_id":"@1xtr/apiapi@2.0.0","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"integrity":"sha512-R7JuQjIP/JGvA7KPTbt0QbPZEZjCyPuPkfIoOe8u3IDNIJbr7rbKQzK7/1EBLfKlzsjVxMYY1UPe7WQ/TxPN/Q==","shasum":"8e46274b07d3e3d19ef1c17518373b2d28981246","tarball":"https://registry.npmjs.org/@1xtr/apiapi/-/apiapi-2.0.0.tgz","fileCount":10,"unpackedSize":35847,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID2BDZ+Y0ruJWKrotPSXwE5b9HzzgkwwS8jYTqmQlVpoAiEApugCwRt+002B4jY5O1QcVItzAGf9Aal+gFqoTW0k1+M="}]},"_npmUser":{"name":"1xtr","email":"i@trendco.dev"},"directories":{},"maintainers":[{"name":"1xtr","email":"i@trendco.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/apiapi_2.0.0_1706523150645_0.45663280495272285"},"_hasShrinkwrap":false},"2.0.1":{"name":"@1xtr/apiapi","version":"2.0.1","description":"Create api clients for node and browser with ease","main":"index.js","module":"index.mjs","exports":{".":{"import":"./index.mjs","require":"./index.js"}},"scripts":{"test":"mocha","eslint":"eslint"},"repository":{"type":"git","url":"git+https://github.com/1xtr/apiapi.git"},"keywords":["api","client","xhr","ajax","rest","fetch"],"author":{"name":"Aleksei Anisimov","email":"i@1xtr.dev"},"license":"MIT","bugs":{"url":"https://github.com/1xtr/apiapi/issues"},"homepage":"https://github.com/1xtr/apiapi","dependencies":{"axios":"^1.6.7","axios-rate-limit":"1.3.0","debug":"4.3.4","http-build-query":"^0.7.0","lodash":"4.17.21","shitty-qs":"1.0.1"},"devDependencies":{"@typescript-eslint/parser":"^5.48.1","bluebird":"^3.7.2","eslint":"^8.31.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.2.1","mocha":"^10.2.0","prettier":"^2.8.2","should":"^13.2.3","sinon":"^15.0.1","typescript":"^4.9.4"},"_id":"@1xtr/apiapi@2.0.1","gitHead":"58b1a807ae29ffb748e2c44e37048f6ad8d49a55","_nodeVersion":"20.11.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-pDY6SrkYLAAC5/Fj7QDZA9gqPyHAO2Ard+vmQXQmiOxCW3eXFR6jQahifkFB5wmcgpMKB7IRuTWKldO9TFsCSg==","shasum":"bbe9378bd440235dfdd8c3aa4c7eef09710393ac","tarball":"https://registry.npmjs.org/@1xtr/apiapi/-/apiapi-2.0.1.tgz","fileCount":10,"unpackedSize":39548,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG2YFd4YOdy2D80AhPYRVHy6FB3HfKCyo94RvNb+aDYLAiA7BgRBzhkzSFV5xJegDX6QXxrtmMHrUSD/unP4zLNYPg=="}]},"_npmUser":{"name":"1xtr","email":"i@trendco.dev"},"directories":{},"maintainers":[{"name":"1xtr","email":"i@trendco.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/apiapi_2.0.1_1707428797464_0.8809055906082752"},"_hasShrinkwrap":false}},"time":{"created":"2022-08-09T15:31:32.082Z","1.0.3":"2022-08-09T15:31:32.272Z","modified":"2024-02-08T21:46:37.836Z","1.1.2":"2023-01-09T21:31:01.933Z","1.1.3":"2023-01-09T21:54:57.634Z","2.0.0":"2024-01-29T10:12:30.828Z","2.0.1":"2024-02-08T21:46:37.656Z"},"maintainers":[{"name":"1xtr","email":"i@trendco.dev"}],"description":"Create api clients for node and browser with ease","homepage":"https://github.com/1xtr/apiapi","keywords":["api","client","xhr","ajax","rest","fetch"],"repository":{"type":"git","url":"git+https://github.com/1xtr/apiapi.git"},"author":{"name":"Aleksei Anisimov","email":"i@1xtr.dev"},"bugs":{"url":"https://github.com/1xtr/apiapi/issues"},"license":"MIT","readme":"### It's fork of [apiapi](https://github.com/boo1ean/apiapi)\n\n### In this fork\n\n- Updated all dependencies\n- Added ESM version\n- Added request limiter for Axios (**Default is 7 RPS**)\n- Added `http-build-query` for build correct query params (e.g. now allow nested objects)\n- Add query and body payload from field in params (set param as string, instead string[],see example below)\n\n## Api client for lazy devs\n\nQuickly write up any json api client for your purpose.\n\nYou can use both callbacks and promises for api client methods.\n\n## Last update\n\nHere is a partial of ApiClient options:\n```json5\n{\n  methods: {\n    posts: 'GET /posts/{userId}?limit={limit}',\n    postsAdd: 'PUT /posts/{postId}',\n  },\n  query: {\n    // posts: ['limit', 'userId'], // old solution work too\n    posts: 'queryParams', // now you can set field for query params\n    postsAdd: ['postId'],\n  },\n  body: {\n    postsAdd: 'payload', // now you can set field for req body\n  }\n}\n```\n\nMake GET request:\n```js\nconst payload = {\n  userId: 1,\n  limit: 5,\n  queryParams: {\n    offset: 3,\n    filter: {\n      id: [1,2]\n    }\n  }\n}\nconst resp = await client.posts(payload)\n// Will exec with url:\n// 'https://.../posts/1?offset=3&filter%5Bid%5D%5B0%5D=1&filter%5Bid%5D%5B1%5D=2'\n```\n\nNow for POST/PUT/PATCH\n```js\nconst putPayload = {\n  postId: 3,\n  payload: {\n    id: 3,\n    title: 'foo',\n    body: 'bar',\n    userId: 1,\n  }\n}\nconst resp = await client.postsAdd(putPayload)\n\n// Will exec with:\nconst reqOpts = {\n  method: 'PUT',\n  url: 'https://jsonplaceholder.typicode.com/posts/3',\n  responseType: 'json',\n  headers: {},\n  data: { id: 3, title: 'foo', body: 'bar', userId: 1 } } }\n}\n```\nNow don't need to create any `transformRequest`, and set all payload fields by default lib behavior.\n\nEnjoy =)\n\n## Installation\n\n```bash\nnpm install @1xtr/apiapi\n```\n\n## Import\n\n```js\n// ES5 example\nconst ApiClient = require('1xtr/apiapi')\n// ES6+ example\nimport { ApiClient } from '1xtr/apiapi'\n```\n\n## Example usage\n\nSample api client for github\n\n```js\nconst ApiClient = require('1xtr/apiapi')\n\nconst github = new ApiClient({\n  baseUrl: 'https://api.github.com',\n  // Set rate limit\n  rateLimitOptions: { maxRPS: 7 },\n  // Define api methods\n  methods: {\n    issues: 'get /repos/{user}/{repo}/issues',\n  },\n\n  // Github api requires proper user-agent to work\n  headers: {\n    'user-agent':\n      'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.91 Safari/537.36',\n  },\n})\n\n// will request https://api.github.com/repos/boo1ean/casual/issues?state=closed and return json data\ngithub.issues({ user: 'boo1ean', repo: 'casual', state: 'closed' }).then(console.log)\n\n// also you can use custom headers for each request\ngithub\n  .issues({ user: 'boo1ean', repo: 'casual', state: 'closed' }, { headers: { Authentication: 'token GITHUB-TOKEN' } })\n  .then(console.log)\n```\n\nCall methods passing callbacks\n\n```javascript\n// Call method with params\ngithub.issues({ user: 'boo1ean', repo: 'casual', state: 'closed' }, function (err, result) {\n  // process result\n})\n\n// Call method without params\ngithub.issues(function (err, result) {\n  // process result\n})\n```\n\n## Transform response\n\nYou can specify response transform function:\n\n```js\n// Will transform all methods responses (global transform)\nnew ApiClient({\n  // ...\n  transformResponse: function transformResponse(res, body, requestParams) {\n    // res - request's response object\n    // body = response body\n    // requestParams = object passed to called method\n  },\n})\n\n// transform response of specific method\nnew ApiClient({\n  // ...\n  methods: {\n    issues: 'get /issues',\n  },\n  transformResponse: {\n    issues: function parseIssues(res, body, requestParams) {\n      return body.slice(0, 5)\n    },\n  },\n})\n```\n\n## Transform request\n\nYou can decorate request params and headers with `transformRequest` hooks.\n\n```javascript\n// params - object passed to method\n// requestBody - object which will be used as request body\n// opts - additional request options (e.g. headers)\nvar client = new ApiClient({\n  transformRequest: function transformRequest(params, requestBody, opts) {\n    // You should return overrides for given objects\n    opts.headers = { 'x-some-header': 'header-value' }\n    return [params, requestBody, opts]\n  },\n})\n```\n\nAlso you can perform method-specific `transformRequest` hook:\n\n```javascript\nnew ApiClient({\n  transformRequest: {\n    issues: function transformParams(params) {\n      // ...\n    },\n  },\n})\n```\n\nIf you want to create async request transformer, just return a promise\n\n```javascript\nnew ApiClient({\n\ttransformRequest: {\n\t\tissues: function transformParams (params) {\n\t\t\treturn new Promise(...);\n\t\t}\n\t}\n});\n```\n\n## Pick specific params for query string\n\n```javascript\nvar client = new ApiClient({\n  methods: {\n    issues: 'get /repos/{user}/{repo}/issues',\n  },\n\n  query: {\n    // Will pick only these params for issues method and omit all others\n    issues: ['state'],\n  },\n})\n\n// will request https://api.github.com/repos/boo1ean/casual/issues?state=closed\nclient.issues({ custom: 'custom param', user: 'boo1ean', repo: 'casual', state: 'closed' })\n```\n\n## Pick specific params for request body\n\n```javascript\nvar client = new ApiClient({\n  methods: {\n    createSomething: 'post /something',\n  },\n\n  body: {\n    // Only title will be picked from method params and passed to request body\n    createSomething: ['title'],\n  },\n})\n```\n\n## Response type\n\nBy default response type is `json` but you can change it if you want to one of `arraybuffer`, `blob`, `document`, `json`, `text`.\n\n```javascript\nnew ApiClient({\n  // ...\n  responseType: 'text',\n})\n```\n\n## Set error handler\n\nGlobal error handler\n\n```javascript\nvar client = new ApiClient({\n  errorHandler: function errorHandler(result) {\n    console.log('API error response status code %s', result.status)\n  },\n})\n```\n\nmethod-specific error handlers:\n\n```javascript\nvar client = new ApiClient({\n  errorHandler: {\n    getIssues: function handleGetIssuesError(res) {\n      console.log('Get issues error response status code %s', result.status)\n    },\n  },\n})\n```\n\n## Params validation\n\nYou can declare list of required params for methods\n\n```javascript\nvar client = new ApiClient({\n\tmethods: {\n\t\tcreateIssue: 'post /issues'\n\t},\n\n\trequired: {\n\t\tcreateIssue: ['name', 'body', 'author_id']\n\t}\n});\n\n// Automatically asserts params object for having required attrs\nclient.createIssue({...});\n```\n\n## Raw response body\n\nBy default response body is expected to be json and will be automatically parsed, to get raw body use flag:\n\n```javascript\nvar client = new ApiClient({\n  // ...\n  rawResponse: true,\n})\n```\n\n## Debug\n\nTo see debug output just run you script like this:\n\n```\nDEBUG=apiapi node script.js\n```\n\nDebug output is provided by [debug](https://github.com/visionmedia/debug)\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md)\n\n## License\n\nMIT\n","readmeFilename":"README.md"}