{"_id":"@arthurdenner/use-fetch","_rev":"3-811b564f869d35ed14b19732e31f1595","name":"@arthurdenner/use-fetch","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"@arthurdenner/use-fetch","version":"1.0.0","description":"React hook to fetch data with useful features.","main":"./dist/use-fetch.cjs.js","module":"./dist/use-fetch.esm.js","types":"./types/index.d.ts","keywords":["react","hooks","fetch"],"author":{"name":"Arthur Denner","email":"arthurdenner7@gmail.com"},"scripts":{"add-contributor":"all-contributors add","prebuild":"rimraf dist types","build":"rollup -c && tsc","preversion":"npm test","prepare":"npm run build","version":"conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md"},"repository":{"type":"git","url":"git+https://github.com/arthurdenner/use-fetch.git"},"license":"MIT","bugs":{"url":"https://github.com/arthurdenner/use-fetch/issues"},"homepage":"https://github.com/arthurdenner/use-fetch#readme","peerDependencies":{"react":"^16.8.0"},"devDependencies":{"@babel/core":"^7.3.4","@babel/preset-env":"^7.3.4","@babel/preset-typescript":"^7.3.3","@types/react":"^16.8.8","@typescript-eslint/eslint-plugin":"^1.5.0","@typescript-eslint/parser":"^1.5.0","all-contributors-cli":"^6.2.0","conventional-changelog-cli":"^2.0.12","eslint":"^5.15.3","eslint-plugin-react-hooks":"^1.6.0","husky":"^1.3.1","lint-staged":"^8.1.5","prettier":"^1.16.4","react":"^16.8.5","rimraf":"^2.6.3","rollup":"^1.6.0","rollup-plugin-babel":"^4.3.2","rollup-plugin-commonjs":"^9.3.4","rollup-plugin-node-resolve":"^4.2.3","typescript":"^3.3.3333"},"dependencies":{"@sindresorhus/string-hash":"^1.2.0"},"gitHead":"502cb123bba552b101df3ddea5c232be81d63a4b","_id":"@arthurdenner/use-fetch@1.0.0","_npmVersion":"6.5.0-next.0","_nodeVersion":"11.6.0","_npmUser":{"name":"arthurdenner","email":"arthurdenner7@gmail.com"},"dist":{"integrity":"sha512-ziaZwfeq+bx4BazjC9ucyMohfgBZj18OB5xdeZvDHUniQcbTBVGAWbcMS5lYygbOu3Q4cfnunTZI8Ll7DMk54w==","shasum":"21fd80a2be1369d9b2b3ca55bc9422656f9bab52","tarball":"https://registry.npmjs.org/@arthurdenner/use-fetch/-/use-fetch-1.0.0.tgz","fileCount":6,"unpackedSize":22611,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcw16sCRA9TVsSAnZWagAA2csQAJnqwwq+1e6fqZAF1zH1\n4qGYlcD2VdTo4rsZq6g7HptyYRPNsmJ0nF+gskSSHOJbCfWIxR0v3w1CMS0s\niBRUUmUSbZ2Zb2x5Zn+7VHMMH+cOfww+BGpzvS8hURD1dysws9GIx+P/caGq\nNEAtsTbZSJ/rxKm/3XG28VX2VJmysiPuBqj69+1wGxqaE5kjWWY9npwx8ASA\nfViyCe5JejYuq36TAsX/wFDpnLHY5ba8C0QXOQsSLyGdy0JACMs6kLRdYVpg\nfD2CHzOYdI735HwjjoU/B/RJ5EwQhXk4P209RiOF1KLalf8G1bQBMKLutPQS\nXXnrOiQ7532fcJ0b87wHVYAyFmR+NZSiijv5Wy0K4ksQZXZOK74ZSWSt51zk\n5tbM8w4tvOhzPllxN3S9LIdfqYBa04xuVEtDZJfJNKlRhdOWt21xXcwf+idd\nd4vxBsBgrqOfZ3Y66iCUsZHGDqZ4WcwjLEFeYIZkroeCUSD3wzVdPtiOQrf7\nsDcJgdi4QcnMr2PPlNFCj2CTudJJ+W+JTpeUnULpdQwrc8J+K5n1y3COmAtX\n/xr32inHJRXUjUDhFEZXMpYehAkWCjQlzOvoOneTAFPKuHviqI+yiQQcjEtf\nuQV/IhDZWLT5a4VGf3pZz1KA6JPID+w4a03hJMjDEmZMHut/7DBXX0mvPOcO\nDbBT\r\n=momx\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAcK24rUE2i++iZjTjFPZ36mt/qIGNrq8NIvUCzJZdx0AiAGlLSioWElNo0MY25sAdblud0ZWTQvMcEmfWHUCOdFtg=="}]},"maintainers":[{"name":"arthurdenner","email":"arthurdenner7@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-fetch_1.0.0_1556307627592_0.32344868727556975"},"_hasShrinkwrap":false},"1.1.0":{"name":"@arthurdenner/use-fetch","version":"1.1.0","description":"React hook to fetch data with useful features.","main":"./dist/use-fetch.cjs.js","module":"./dist/use-fetch.esm.js","types":"./types/index.d.ts","keywords":["react","hooks","fetch"],"author":{"name":"Arthur Denner","email":"arthurdenner7@gmail.com"},"scripts":{"add-contributor":"all-contributors add","prebuild":"rimraf dist types","build":"rollup -c && tsc","preversion":"npm test","prepare":"npm run build","version":"conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md"},"repository":{"type":"git","url":"git+https://github.com/arthurdenner/use-fetch.git"},"license":"MIT","bugs":{"url":"https://github.com/arthurdenner/use-fetch/issues"},"homepage":"https://github.com/arthurdenner/use-fetch#readme","peerDependencies":{"react":"^16.8.0"},"devDependencies":{"@babel/core":"^7.3.4","@babel/preset-env":"^7.3.4","@babel/preset-typescript":"^7.3.3","@types/react":"^16.8.8","@typescript-eslint/eslint-plugin":"^1.5.0","@typescript-eslint/parser":"^1.5.0","all-contributors-cli":"^6.2.0","conventional-changelog-cli":"^2.0.12","eslint":"^5.15.3","eslint-plugin-react-hooks":"^1.6.0","husky":"^1.3.1","lint-staged":"^8.1.5","prettier":"^1.16.4","react":"^16.8.5","rimraf":"^2.6.3","rollup":"^1.6.0","rollup-plugin-babel":"^4.3.2","rollup-plugin-commonjs":"^9.3.4","rollup-plugin-node-resolve":"^4.2.3","typescript":"^3.3.3333"},"dependencies":{"@sindresorhus/string-hash":"^1.2.0"},"gitHead":"bc5c411524384d21e4a9004fa1fbf41bbe19cae1","_id":"@arthurdenner/use-fetch@1.1.0","_nodeVersion":"12.2.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-v7eyOEk2sdKY8mjquaRs/qdBKD+SB1g2dlfnkLuzPVgOhhmUo9GFTfWq5HyvVHH09BO3JgjeKMeahI42up/Pvg==","shasum":"6ba14ac6c1179cc693d7c9c1849539de1b92571b","tarball":"https://registry.npmjs.org/@arthurdenner/use-fetch/-/use-fetch-1.1.0.tgz","fileCount":7,"unpackedSize":21699,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc8WVlCRA9TVsSAnZWagAA8DsP+watArAY7aIXI51gNuWx\n2mmfqs43reVziVnmgDEYFGFVPIF9262Ics9VplzYV8uLhfIiCVPYJgGc1bgQ\nLlqiXOov684U8ZU1eJza97e7tjZ/epRElIOdiIeYuRv4cNfW8DAvsFGqkRd0\n4pYFNUfD8fx56DEx1ArK4Annklsx0zdA9pcTnjQZCtT7Yp8d8SD6jWA3Z6SE\nEz/oAkHBDbnM5Sw69mj/oAQecTTZjHYYdRbBQORLdCgT9jRz5CknxqIZW8Z/\nhqWFxnemJ3DYAwKAYisBFR9HUssHABGejVVKr18BbbqsDTATsLsiGer5vlxj\nM0Frl2gYSCMMVbpgCyIZutW/mFTbrwVK9wO/KPymZG3WEknNcbNO9SFVGN8O\nIWKhcszvJLzi+P4lFFQGS6CKCqfXyiB2iL1Q8j9IcFBHIZTDPsilbMMsKr/P\nWuqfucyUnJ7v2hBdZzXrOHcYQM8hj2t5dtB0Z84+vhZYPL9FlLmF/DppnHus\n2bdP+1+Y079FoAx6nT5vrM2qD0VDKKHnI6c+Vi0809FccmqxhzFqOJgFwpzf\nb4bjYROoho7ABX3mVNUbhHtMaGc5O/OZnE5ZL2MK1sUK9MhdDvXBciUz/2Ig\nwP6UfMd5wDNCp63d8pIKxoB5gGFnUTgW+1U1rFdIvzhtUsldbO3MQ3qGcOW8\nNcD5\r\n=DI0I\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDqPbWq5qX19dUbSz6OFhsEoFHgPN0M2cvKscLVDTzf5QIgIvNoLI92YAOc3nVwn3JCvTTxRTQCKBLDgdPKKkMckdQ="}]},"maintainers":[{"name":"arthurdenner","email":"arthurdenner7@gmail.com"}],"_npmUser":{"name":"arthurdenner","email":"arthurdenner7@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-fetch_1.1.0_1559324004317_0.27552539820176514"},"_hasShrinkwrap":false},"2.0.0":{"name":"@arthurdenner/use-fetch","version":"2.0.0","description":"React hook to fetch data with useful features.","main":"./dist/use-fetch.cjs.js","module":"./dist/use-fetch.esm.js","types":"./types/index.d.ts","keywords":["react","hooks","fetch"],"author":{"name":"Arthur Denner","email":"arthurdenner7@gmail.com"},"scripts":{"add-contributor":"all-contributors add","prebuild":"rimraf dist types","build":"rollup -c && tsc","preversion":"npm test","prepare":"npm run build","version":"conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md"},"repository":{"type":"git","url":"git+https://github.com/arthurdenner/use-fetch.git"},"license":"MIT","bugs":{"url":"https://github.com/arthurdenner/use-fetch/issues"},"homepage":"https://github.com/arthurdenner/use-fetch#readme","peerDependencies":{"react":"^16.8.0"},"devDependencies":{"@babel/core":"^7.3.4","@babel/preset-env":"^7.3.4","@babel/preset-typescript":"^7.3.3","@types/react":"^16.8.8","@typescript-eslint/eslint-plugin":"^1.5.0","@typescript-eslint/parser":"^1.5.0","all-contributors-cli":"^6.2.0","conventional-changelog-cli":"^2.0.12","eslint":"^5.15.3","eslint-plugin-react-hooks":"^1.6.0","husky":"^1.3.1","lint-staged":"^8.1.5","prettier":"^1.16.4","react":"^16.8.5","rimraf":"^2.6.3","rollup":"^1.6.0","rollup-plugin-babel":"^4.3.2","rollup-plugin-commonjs":"^9.3.4","rollup-plugin-node-resolve":"^4.2.3","typescript":"^3.3.3333"},"dependencies":{"@sindresorhus/string-hash":"^1.2.0"},"gitHead":"5421460e6b3942654494884a6195ec16ff99ebfd","_id":"@arthurdenner/use-fetch@2.0.0","_nodeVersion":"12.2.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-HOIoR47axWPOEJ7XjEgLvcx/fMM0fQk5Z1VLp7hBHxklAyDg8fUTOUuwUCZQRHafvc22CPlhknGwL+VkR9hh0A==","shasum":"7dd91bfd3592170b12a49885ad17f4445cd6cbcf","tarball":"https://registry.npmjs.org/@arthurdenner/use-fetch/-/use-fetch-2.0.0.tgz","fileCount":7,"unpackedSize":22865,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc9Q3ACRA9TVsSAnZWagAAa3kP/i62t47q85Rg//yp3r75\nBwg2yd0XEVj8Z1h1HbNzVdUt0aIkXkYYlSPXtrXTjvPRjXrX6aeGjFRQ0U9D\n81YcDapBPOuCHwi2iTBXHBqgBbWxp/jRdFueG4tY9OvxIi5Kklg2lLSB9zJL\n4PaAnYxOnir8jTCwrv+riOV/ZoDtHsDHzcUM/0unK7dCtzdlprxOyGDJKXeu\nLXh0tw3OlcuA35v9DA+hYAW4IXhVUUhI+bEwteJxhh/YsvkoXSo514V9NSSU\ncsZCV/iuerJ4zJ80C4icJHkPxlKgZIfFBPbb47mFdhO3bwrfAQJjZOcMHIAs\n6cPPw4bjH7dayTLjk2RtmBz67J3/tH8PpP2dPJbS4jY8+D4MN1Jxjd7F2KMW\nZ9LYHW59ql+wlzry6VWOi7PjCcEa1xA5HHor+OSBmufbfTWVjUt2HIRlGXC5\nRwPvprDw+K2uPkMgkOTlSemz5R3tI6fjSVYo3ECa5+5BSd7/8ZdkeuP0LWTx\ngkRzPc/5LCvoYQDrdghXL2hkc49HSo+BGPOsZz9rQwz9aDi0Ftz0sJmK/QVU\npPnWtku40jNdPCJdnTrQS5f4i6ePtcrzDJVwJhOlSM7r6BYiDjnab3j1l5dy\nDsmZYVw3k12UV3N4jowzTKNW9SR203iynBs0vXfPayMmRN1JQ/GaIp8ofQ5f\nRL34\r\n=/n/H\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDtfm7f++dAaAt2h/puj6t8eNUp8JaDSiKs/DNEka9gBAIgXyrYOMX2DQLulTZim4BSlABNWd7iHDH+rvmAlmBr6yY="}]},"maintainers":[{"name":"arthurdenner","email":"arthurdenner7@gmail.com"}],"_npmUser":{"name":"arthurdenner","email":"arthurdenner7@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/use-fetch_2.0.0_1559563711429_0.9681356459754804"},"_hasShrinkwrap":false}},"time":{"created":"2019-04-26T19:40:27.407Z","1.0.0":"2019-04-26T19:40:27.729Z","modified":"2022-04-04T15:37:35.116Z","1.1.0":"2019-05-31T17:33:24.422Z","2.0.0":"2019-06-03T12:08:31.607Z"},"maintainers":[{"name":"arthurdenner","email":"arthurdenner7@gmail.com"}],"description":"React hook to fetch data with useful features.","homepage":"https://github.com/arthurdenner/use-fetch#readme","keywords":["react","hooks","fetch"],"repository":{"type":"git","url":"git+https://github.com/arthurdenner/use-fetch.git"},"author":{"name":"Arthur Denner","email":"arthurdenner7@gmail.com"},"bugs":{"url":"https://github.com/arthurdenner/use-fetch/issues"},"license":"MIT","readme":"# @arthurdenner/use-fetch\n\n[![npm](https://img.shields.io/npm/v/@arthurdenner/use-fetch.svg)](https://www.npmjs.org/package/@arthurdenner/use-fetch)\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg)](#contributors)\n[![gzip size](https://img.badgesize.io/https://unpkg.com/@arthurdenner/use-fetch/dist/use-fetch.cjs.js?compression=gzip)](https://unpkg.com/@arthurdenner/use-fetch/dist/use-fetch.cjs.js)\n[![install size](https://packagephobia.now.sh/badge?p=@arthurdenner/use-fetch)](https://packagephobia.now.sh/result?p=@arthurdenner/use-fetch)\n\nReact hook to fetch data with useful features.\n\n## Install\n\n```\nyarn add @arthurdenner/use-fetch\n```\n\n```\nnpm i @arthurdenner/use-fetch\n```\n\n## Usage\n\n```javascript\nimport React from 'react';\nimport useFetch from '@arthurdenner/use-fetch';\n\nfunction App() {\n  const { data: users, error, loading } = useFetch({\n    initialData: [],\n    url: 'https://jsonplaceholder.typicode.com/users',\n  });\n\n  if (error) {\n    console.log(error);\n    return <div>An error occured!</div>;\n  }\n\n  if (loading) {\n    return <div>Loading...</div>;\n  }\n\n  return (\n    <div>\n      <ul>\n        {users.map(user => (\n          <li>{user.name}</li>\n        ))}\n      </ul>\n    </div>\n  );\n}\n```\n\n## Features\n\n- TypeScript-friendly\n- JSONP support\n- localStorage cache support\n  - You don't pass a `cacheKey`, the hash of the URL will be used\n- Abort request support (manually and when the component unmounts)\n\n## Config\n\n| name        | type        | required | description                             |\n| ----------- | ----------- | -------- | --------------------------------------- |\n| cacheKey    | string      | no       | localStorage key to store the response  |\n| expiryTime  | number      | no       | amount of time to cache the response    |\n| initialData | T           | yes      | initial data for the hook               |\n| isJsonP     | boolean     | no       | indicates if the URL returns JSONP data |\n| options     | RequestInit | no       | options accepted by the `fetch` API     |\n| url         | string      | yes      | URL to be fetched                       |\n\n## Return\n\n| name     | type               | description                             |\n| -------- | ------------------ | --------------------------------------- |\n| abort    | () => void         | callback function to cancel the request |\n| start    | () => void         | callback function to fire the request   |\n| data     | T                  | data returned from the request          |\n| error    | Error \\| undefined | error occurred on the request           |\n| loading  | boolean            | indicates if the request is being made  |\n| canceled | boolean            | indicates if the request was canceled   |\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore -->\n<table><tr><td align=\"center\"><a href=\"https://github.com/arthurdenner\"><img src=\"https://avatars0.githubusercontent.com/u/13774309?v=4\" width=\"100px;\" alt=\"Arthur Denner\"/><br /><sub><b>Arthur Denner</b></sub></a><br /><a href=\"https://github.com/arthurdenner/use-fetch/commits?author=arthurdenner\" title=\"Code\">💻</a> <a href=\"#design-arthurdenner\" title=\"Design\">🎨</a> <a href=\"https://github.com/arthurdenner/use-fetch/commits?author=arthurdenner\" title=\"Documentation\">📖</a> <a href=\"#example-arthurdenner\" title=\"Examples\">💡</a> <a href=\"#ideas-arthurdenner\" title=\"Ideas, Planning, & Feedback\">🤔</a> <a href=\"#maintenance-arthurdenner\" title=\"Maintenance\">🚧</a></td></tr></table>\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n## License\n\nMIT © [Arthur Denner](https://github.com/arthurdenner/)\n","readmeFilename":"README.md"}