{"_id":"@0y0/request","_rev":"3-039ce0a743f354915745ef01d0616feb","name":"@0y0/request","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@0y0/request","version":"1.0.0","description":"Easy-to-fetch HTTP client for the browser.","main":"dist/request.cjs.js","browser":"dist/request.min.js","repository":{"type":"git","url":"https://github.com/o0y0o/request"},"author":{"name":"Jason Chung","email":"shiningjason1989@gmail.com"},"license":"MIT","publishConfig":{"access":"public"},"keywords":["fetch","http","https","http-client","http-request","network","request"],"scripts":{"format":"prettier --write '{*,src/**/*}.js'","lint":"eslint '{*,src/**/*}.js'","test":"BABEL_ENV=test mocha -r @babel/register src/**/*.test.js","prebuild":"yarn lint && yarn test","build":"rollup -c"},"devDependencies":{"@babel/core":"^7.11.1","@babel/plugin-transform-runtime":"^7.11.0","@babel/preset-env":"^7.11.0","@babel/register":"^7.10.5","@rollup/plugin-babel":"^5.1.0","babel-eslint":"10.1.0","eslint":"^7.7.0","eslint-config-prettier":"^6.11.0","fetch-mock":"^9.10.6","form-data":"^3.0.0","mocha":"^8.1.1","node-fetch":"^2.6.0","rollup":"^2.25.0","rollup-plugin-terser":"^7.0.0"},"optionalDependencies":{"prettier":"^2.0.5"},"licenseText":"The MIT License (MIT)\n\nCopyright (c) 2020 Jason Chung\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"@0y0/request@1.0.0","dist":{"shasum":"55709d07e7b6237072ba73aa886cd08574026f79","integrity":"sha512-sWVC4Js8UU+TZNAQywhLeHOpk824Hvnf2T+19FKhIgmT/eSV+nnpGpzNMdmgTsPEPq0cPP1fnuYG84c5I93J4A==","tarball":"https://registry.npmjs.org/@0y0/request/-/request-1.0.0.tgz","fileCount":7,"unpackedSize":10576,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOTJzCRA9TVsSAnZWagAAEh0P/2pert8NcBj5bEJgM3RR\noZPXvqGKGgPPHGJt84PTVurOEvmEUapmQd06wFO6ymgsQIJSvv9XfGKcmd3V\n5R6YrT3zFG467ft0Uq1ODlIoWZIyW6ESKELSvwVs7eVLNqk9+sF4drrBRAtM\nB8bnGicwbeP+4F53JQQsD6HHJNoRWHpJq3uDjXvN+aSuUmaLcSNtOR2BdcZB\n3w5TxJSjiwi0zjpEDbZXlDcxIEz/oYKiCeol5EPzbR1xZ1qSSjvpLd4+DViw\nAFZl9oy8mC03gUHD8uvlSICIBL9/7DCdiH6zla+xU4/K0YTzLzt5ZK/2fVFf\nRVAupkZVAXRLYCRBYqIx2exOhvJtMuha4LkpyNikedvKeZhvZby4aICOZJSy\nIjGVUZXpFx2j3rs53AiC9LAMCjnROnS1ZT9rs02IgYbychPZWzA+f4x7NAHO\n3IkoQtDMDc4Qh9oUDEzOuWONmFyD882KEqQfrFem+ELytGaq5sVPO2K0vXVj\nxYO0IaDPeRAvpxojDTyZ0uO+QoBaf8r4hl0bu2oD9L3/PAVvtAWN0RuLZUaH\n9Fs52XoBWm0y+5n0bhq5/iQRrWtD+iZf67+kxrcQwZPfn/oiYes1i7MGAWyF\nfNrqP8FwNTUty/hBmtzxSzLfEd08YDxVCLcqRu7iCgysdHPIcevuIAZzLcat\n/eDp\r\n=Hatz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDAxbYsXdwJ8hKlqDUlGYlwlg/ctLVi/JumhdkR3B4KcAIgR1IEHVEK/LFrdIix4c7Uw09OKVdBNPCXiYycni0S7F8="}]},"maintainers":[{"name":"shiningjason","email":"shiningjason1989@gmail.com"}],"_npmUser":{"name":"shiningjason","email":"shiningjason1989@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/request_1.0.0_1597583986638_0.48036509338161637"},"_hasShrinkwrap":false},"1.0.1":{"name":"@0y0/request","version":"1.0.1","description":"Easy-to-fetch HTTP client for the browser.","browser":"request.min.js","main":"request.js","repository":{"type":"git","url":"https://github.com/o0y0o/request"},"author":{"name":"Jason Chung","email":"shiningjason1989@gmail.com"},"license":"MIT","publishConfig":{"access":"public"},"keywords":["fetch","http","https","http-client","http-request","network","request","web","browser"],"_id":"@0y0/request@1.0.1","dist":{"shasum":"77c955ed758b5e169aefcbed4421d9ac73537d0b","integrity":"sha512-lOxsZnrGecXb+br6QErp1mWGpE6QxQ7vpbOFnQkM+iRYi2CAJi+rDl5SsW2Nr0DLmBI7VO/TpRaFkhqbS87EkQ==","tarball":"https://registry.npmjs.org/@0y0/request/-/request-1.0.1.tgz","fileCount":5,"unpackedSize":8729,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOUqqCRA9TVsSAnZWagAAJu0QAJLsihGlNeFuisU1+Dpi\nw+hj1lO4lJN8iujQFa97B/VKAygnzv0itO7XLzxEFOde7zeGbYCLd58WcK/m\neaHOOzBfwWo9kwefy7dV33J5P9DuDgGaRKX92pBfgLbpVL5wpcRXFyIPJ9SF\nX/ekALCeZYfW0zEadyqANWKgkXHul1Pdk0TlYRThN2I4qj+iQd4UFLGQxHW+\naShO+MD8Ttz0j2f5bSneQdTcmdVKMAI+GZTT8ThtS7aHE5npWLm/ANA1dwIO\nhq2sc5B8vhFSyO+nR5cJoOFOkwU0pEHkOTjHjx3Ik3NzRirN7CAMwRbzYpug\nbo6wGNN55ehdwiIWvDMwE6A0JqaDUKp+4OYy1g1ldqRTYXkQ1WFXsv5axbvl\n0nt2hyHW5Ma46CDTlkGohBcWXIvj4UDAQ2dSYQ4LTt/g+SKp/pdK+XkpoNV+\nw/Mpiwtpf/iESckYafnH6XyCbJpQDbZeRt2tr3ZnwlcB0AAtArgL6UbdT1OM\nqzH8ZWiW307h3F7PB39W9Be4Booz9R0OCWVTFgQolm1eMuxvj3fJ+e1W8ZBO\njBILMOLyoJAyYg1UqS3DoeM/VyWPXuMblLMiTmnvYw5Oo7KQNIdfkYW+BRhc\nYvGbdM2mXS2YciZszRx0l30bZZftGLeNudamibnVGj/KqfBVMBV4sWzYjcSd\nYbOB\r\n=WRMt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH3AfZAWNWGNY8+9oErBygqV3N71+fjd7HNUfBPxvh1XAiEAq5j1n1Wjft4XzGALkUT3ND+JQiyUj3F/YTRD201cacs="}]},"maintainers":[{"name":"shiningjason","email":"shiningjason1989@gmail.com"}],"_npmUser":{"name":"shiningjason","email":"shiningjason1989@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/request_1.0.1_1597590186344_0.4515534551734841"},"_hasShrinkwrap":false},"1.0.2":{"name":"@0y0/request","version":"1.0.2","description":"Easy-to-fetch HTTP client for the browser.","main":"request.js","iife":"request.min.js","repository":{"type":"git","url":"git+https://github.com/o0y0o/request.git"},"author":{"name":"Jason Chung","email":"shiningjason1989@gmail.com"},"license":"MIT","publishConfig":{"access":"public"},"keywords":["fetch","http","https","http-client","http-request","network","request","web","browser"],"gitHead":"6f78bec57413d77e233a5289d6fceaed2c8b28f3","bugs":{"url":"https://github.com/o0y0o/request/issues"},"homepage":"https://github.com/o0y0o/request#readme","_id":"@0y0/request@1.0.2","_nodeVersion":"14.10.1","_npmVersion":"lerna/3.22.1/node@v14.10.1+x64 (linux)","dist":{"integrity":"sha512-zL9era5CR7lnk/YfCAdptCPGQ79fl26Uz1JPNgM/9rfpNPKtTTEUOE/nqKa67aotjXGNCtj0ovIHKKF9/n6uPQ==","shasum":"67e699c9660ad90baf382d87ee00b8821f920c52","tarball":"https://registry.npmjs.org/@0y0/request/-/request-1.0.2.tgz","fileCount":5,"unpackedSize":9812,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfasZUCRA9TVsSAnZWagAAoSwP/0Vr0+JZyiKS1c7tnddA\n5yXIRt+Vpx7wxw81QB0sIn3IsWrvX+ag+ws0JaN7Hj6qAY98BtfEbRsTh6a0\nuPWGjhHqqlD9OyJK+cTT/2bfYmMchthLMaW4CpTv+ETYcxbI4RRZlnklLRCF\ngU79NrmM+dB3WhG+8sWMsbKHyvnehVcelL290YO259Rk/g+cu25EPJv8uvZH\nTtZpY/NcjKn2ASBJFlaBDO/9pHDXwokWMbru3ooN8N4m29YaRNeb1KaH7aPe\nBdobIJWWpYoSeca4NsfKCHIg+khmwWUtEJIATvOxf8PkpU4huzsEv2FGjXvq\n2duhDquAOM5q9upKsz2nUUrR86//fPk9F7ctWPjV9VutlKf3IQUhLhb4kfAF\ndd1FWAbVwVwHJ37bhfrBRa7cND5mbUwEfHhkqOYovFPhl23NpLtmnwKdL+kO\nkekFE+3HRi7rRmX0ePFyRWloxyNr+stfP0Ld9Y4JTYABBSMx9vRYLm84mYZn\n9XZOvEDq1a+uj+B8gmvMkbKBKduzzJU4KJMQwgdo39/Cv3bQDX33F3AsTk4A\njNyXAK2nsEbu63U27R3YkLPL7QdNPXvcatShdgE3V2o9hzdwGQjuQHzzHXvr\nPSLu4sCGPIMgeS7oY52HUS0RG3B8K/wX3O6JLrSH54WYjesvFKpmxpVWSmIL\nMAtg\r\n=dJxA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCmILBL8VZv7rIdChva8YYemCo3WrqakOlxTfgUTiph4AIgEUnMNZz02DPjJFcQf9/0wcJWkt0xDfT6W/xP7/4xlYY="}]},"maintainers":[{"name":"shiningjason","email":"shiningjason1989@gmail.com"}],"_npmUser":{"name":"shiningjason","email":"shiningjason1989@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/request_1.0.2_1600833107899_0.8833474954111555"},"_hasShrinkwrap":false}},"time":{"created":"2020-08-16T13:19:46.417Z","1.0.0":"2020-08-16T13:19:46.759Z","modified":"2022-04-04T10:29:41.736Z","1.0.1":"2020-08-16T15:03:06.457Z","1.0.2":"2020-09-23T03:51:48.018Z"},"maintainers":[{"name":"shiningjason","email":"shiningjason1989@gmail.com"}],"description":"Easy-to-fetch HTTP client for the browser.","keywords":["fetch","http","https","http-client","http-request","network","request","web","browser"],"repository":{"type":"git","url":"git+https://github.com/o0y0o/request.git"},"author":{"name":"Jason Chung","email":"shiningjason1989@gmail.com"},"license":"MIT","readme":"# @0y0/request · [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/o0y0o/request/blob/master/LICENSE) [![npm](https://img.shields.io/npm/v/@0y0/request.svg)](https://www.npmjs.com/package/@0y0/request)\n\n`@0y0/request` is a tiny [window.fetch](https://fetch.spec.whatwg.org/) wrapper tried to make HTTP request code more readable and more easy to write.\n\n### Before\n\n```js\nfetch('/users/1', {\n  method: 'PUT',\n  headers: {\n    'Content-Type': 'application/json'\n    'Authorization': 'Bearer this-is-user-token'\n  },\n  body: JSON.stringify({\n    email: 'foo@gmail.com',\n    name: 'bar'\n  })\n}).then(handleResponse, handleError)\n```\n\n### After\n\n```js\nRequest\n  .post('/users/1')\n  .bearer('this-is-user-token')\n  .jsonBody({ email: 'foo@gmail.com', name: 'bar' })\n  .then(handleResponse, handleError)\n```\n\n## Installation\n```\nnpm install @0y0/request --save\n```\n```js\nimport Request from '@0y0/request'\n```\n\nAs an alternative to using npm, you can use `@0y0/request` as a `<script>` tag from a [CDN](https://unpkg.com/@0y0/request/dist/request.min.js). You will also need [Promise polyfill](https://github.com/taylorhakes/promise-polyfill) and [fetch polyfill](https://github.com/github/fetch) for old browsers (Check out compatibility at [caniuse/Promises](https://caniuse.com/#feat=promises) and [caniuse/fetch](https://caniuse.com/#search=fetch)).\n\n```html\n<!--\nUse promise-polyfill and whatwg-fetch only if you want to support old browsers.\nCheck out Promise and fetch compatibility at http://caniuse.com.\n-->\n<script src=\"https://unpkg.com/promise-polyfill\"></script>\n<script src=\"https://unpkg.com/whatwg-fetch\"></script>\n<script src=\"https://unpkg.com/@0y0/request/dist/request.min.js\"></script>\n<script>Request.get('http://...')</script>\n```\n\n## Usage\n\n### Send a request\n```js\nReqeust.get('/api')\nReqeust.post('/api')\nReqeust.put('/api')\nReqeust.delete('/api')\n```\n\n### Set HTTP header\n```js\n// headers: { foo: 'bar' }\nRequest.get('/api').header('foo', 'bar')\n\n// headers: { Authorization: 'bar' }\nRequest.get('/api').auth('bar')\n\n// headers: { Authorization: 'Bearer token' }\nRequest.get('/api').bearer('token')\n\n// headers: { foo1: 'bar1', Authorization: 'token' }\nRequest.get('/api')\n  .header('foo1', 'bar1')\n  .header('foo2', undefined)\n  .auth('token')\n```\n\n### Set URL parameters\n\n```js\n// url: /api/?foo=bar\nRequest.get('/api').param('foo', 'bar')\n\n// url: /api/?foo2=bar2\nRequest.get('/api').param('foo1', undefined).param('foo2', 'bar2')\n\n// url: /api/?foo1=bar1&foo2=bar2\nRequest.get('/api').params({ foo1: 'bar1', foo2: 'bar2' })\n```\n\n### Set request body\n\n```js\nRequest.post('/api').body('content')\n\n// Content-Type: application/json\nRequest.post('/api').jsonBody({ foo: 'bar' })\n\n// Content-Type: multipart/form-data\nRequest.post('/api').formBody({ foo: 'bar' })\n\n// Content-Type: application/x-www-form-urlencoded;charset=UTF-8\nRequest.post('/api').urlencodedFormBody({ foo: 'bar' })\n```\n\n### Handle JSON response\n\n```js\nRequest.get('/api').acceptJson()\n```\n\n## Browser Support\n\n- Chrome\n- Firefox\n- Safari 10.1+\n- IE 10+ (Should use with [Promise](https://github.com/taylorhakes/promise-polyfill), [fetch](https://github.com/github/fetch), [URL, URLSearchParams](https://github.com/lifaon74/url-polyfill) and [FormData](https://github.com/jimmywarting/FormData) polyfills)\n\n## License\n\n[MIT](https://github.com/o0y0o/request/blob/master/LICENSE)\n","readmeFilename":"README.md","homepage":"https://github.com/o0y0o/request#readme","bugs":{"url":"https://github.com/o0y0o/request/issues"}}