{"_id":"@ajay_g/react-fetch","_rev":"1-7164282535886115a1ff57b8b8b65784","name":"@ajay_g/react-fetch","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@ajay_g/react-fetch","version":"1.0.0","description":"A simple react hook to consume REST API's.","author":{"name":"Ajay"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Ajayg96/react-fetch.git"},"bugs":{"url":"https://github.com/Ajayg96/react-fetch/issues"},"keywords":["react","hooks","react-hooks","custom-hooks"],"homepage":"https://github.com/Ajayg96/react-fetch#readme","main":"dist/index.js","module":"dist/index.es.js","jsnext:main":"dist/index.es.js","engines":{"node":">=8","npm":">=5"},"scripts":{"test":"cross-env CI=1 react-scripts test --env=jsdom","test:watch":"react-scripts test --env=jsdom","build":"rollup -c","start":"rollup -c -w","prepare":"npm run build","predeploy":"cd example && npm install && npm run build","deploy":"gh-pages -d example/build"},"peerDependencies":{"react":"^16.9.0"},"devDependencies":{"@babel/core":"^7.0.0","@babel/plugin-external-helpers":"^7.0.0","@babel/plugin-proposal-class-properties":"^7.0.0","@babel/plugin-proposal-decorators":"^7.0.0","@babel/plugin-proposal-do-expressions":"^7.0.0","@babel/plugin-proposal-export-default-from":"^7.0.0","@babel/plugin-proposal-export-namespace-from":"^7.0.0","@babel/plugin-proposal-function-bind":"^7.0.0","@babel/plugin-proposal-function-sent":"^7.0.0","@babel/plugin-proposal-json-strings":"^7.0.0","@babel/plugin-proposal-logical-assignment-operators":"^7.0.0","@babel/plugin-proposal-nullish-coalescing-operator":"^7.0.0","@babel/plugin-proposal-numeric-separator":"^7.0.0","@babel/plugin-proposal-optional-chaining":"^7.0.0","@babel/plugin-proposal-pipeline-operator":"^7.0.0","@babel/plugin-proposal-throw-expressions":"^7.0.0","@babel/plugin-syntax-dynamic-import":"^7.0.0","@babel/plugin-syntax-import-meta":"^7.0.0","@babel/preset-env":"^7.0.0","@babel/preset-react":"^7.0.0","@testing-library/react-hooks":"^3.2.1","babel-eslint":"^10.0.1","cross-env":"^5.2.0","eslint":"5.16.0","eslint-config-standard":"^11.0.0","eslint-config-standard-react":"^6.0.0","eslint-plugin-import":"^2.13.0","eslint-plugin-node":"^7.0.1","eslint-plugin-promise":"^4.0.0","eslint-plugin-react":"^7.10.0","eslint-plugin-standard":"^3.1.0","gh-pages":"^2.0.1","react":"^16.9.0","react-scripts":"^3.4.0","react-test-renderer":"^16.9.0","rollup":"^1.1.2","rollup-plugin-babel":"^4.3.2","rollup-plugin-commonjs":"^9.2.0","rollup-plugin-node-resolve":"^4.0.0","rollup-plugin-peer-deps-external":"^2.2.0","rollup-plugin-url":"^2.1.0"},"gitHead":"641486562c710e2f352dcece11225d91cc82bbe4","_id":"@ajay_g/react-fetch@1.0.0","_nodeVersion":"14.5.0","_npmVersion":"6.14.7","dist":{"integrity":"sha512-wEWsCttJPzxaf/y9brwsAPqlJo20/LPqP2tTLLpqsbCACIwUgF6qeqY4AyAM5GkzMtt0DrNV2JwvKMu/HecqNA==","shasum":"899ad585491984b6d00910e8711b2530444be00c","tarball":"https://registry.npmjs.org/@ajay_g/react-fetch/-/react-fetch-1.0.0.tgz","fileCount":14,"unpackedSize":20945,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3JiGCRA9TVsSAnZWagAAY/IP/1QwXLoI4FN7dL0EdpXn\nE5VaVmWJbOxnEJI4/MYTxUz1Ys7mDoEXUUsFiiB4rG4S732Q4TmDDJrg1x3D\nutajYG0+Q7HEmL/DG3e3LgHr6UmfcphxWd1b9MQqUxCnc8Fht9k4LQ2v1RTB\nAWYRjyO74aXlnpbmP8DAdkPL7/c5LIcVVquIRvfkXo7t6IWxkTKXU62OWggn\ndYMahDUhaqWwKooKHeO00/BeCk3JzigCaVA+onkBiuOntL28YbT+9Kk8i3/q\nH8h5iP6b6zdRy213perciCp/hKUnXb5y00XEAG2KrEkT2iE1PphoTw8HtUBK\n9HeAu6SU+ZTMFqFHWifqtD7jewr0tOGmJ+OuhUwdBZVNZduVosWSjAzCdFYk\nRvj/xxEjDKQO0spWqZi3m46okRRokOx7V5dHc//uUvWVxaqoAYfK1E7RgXMO\nNb2KKK1WEFz0QMgU500BnGlRg/7xazdrlsVh6Rz3w4QfEQ2IdVQOd4Z6scio\nweLGPC6zwXucZsNtK4vBaNOg4w59ZBkFlykgYG2ipJJ2erTUF19+sSK4/qlE\ns20yDqdy4c5Oq8mDJJt/YqdYQp9pOsYGkxCLh5v/Ogv4+pjUGh2Gy/wxr/hb\nZmHTcSxhFKTboPuhnpVZXdKlDVWUn6Q2JCQobb9aAebLTB+QMAjzbYUwJWgk\nBKQ6\r\n=5RgX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDG3HE+4P4u2AOPi7nbKtd0ZB0cekYw4IKc7pY1ea/VigIgWPDxQzCshN89p+WulY9NgeMxq0RT7zC9/u4u+6A9tZI="}]},"_npmUser":{"name":"ajay_g","email":"ajaygaj28@gmail.com"},"directories":{},"maintainers":[{"name":"ajay_g","email":"ajaygaj28@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-fetch_1.0.0_1625069701814_0.6062164479498815"},"_hasShrinkwrap":false}},"time":{"created":"2021-06-30T16:15:01.755Z","1.0.0":"2021-06-30T16:15:01.983Z","modified":"2022-04-04T12:26:23.148Z"},"maintainers":[{"name":"ajay_g","email":"ajaygaj28@gmail.com"}],"description":"A simple react hook to consume REST API's.","homepage":"https://github.com/Ajayg96/react-fetch#readme","keywords":["react","hooks","react-hooks","custom-hooks"],"repository":{"type":"git","url":"git+https://github.com/Ajayg96/react-fetch.git"},"author":{"name":"Ajay"},"bugs":{"url":"https://github.com/Ajayg96/react-fetch/issues"},"license":"MIT","readme":"# React-Fetch-Hook\n\n> A simple react hook to consume REST API's.\n\n[![NPM](https://img.shields.io/npm/v/@ajay_g/react-fetch.svg)](https://www.npmjs.com/package/@ajay_g/react-fetch) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Install\n\n```bash\nnpm install --save @ajay_g/react-fetch\n```\n\n```bash\nyarn add @ajay_g/react-fetch\n```\n\n## Usage\n\n## Fetching data on component render:\n\n```jsx\nimport React from \"react\";\nimport { useFetch } from \"@ajay_g/react-fetch\";\n\nconst GetUser = () => {\n  const [loading, data, error] = useFetch(\"http://localhost:8080/user/1\", {\n    method: \"GET\",\n    // ...other request options\n  });\n\n  if (loading) return \"Loading...\";\n\n  return (\n    <div>\n      <p>{data.userName}</p>\n    </div>\n  );\n};\n```\n\n## Fetching data manually:\n\n```jsx\nimport React, {useState} from \"react\";\nimport { useLazyFetch } from \"@ajay_g/react-fetch\";\n\nconst GetAllPosts = () => {\n  const [posts, setPosts] = useState([])\n  const [getAllPosts, loading, error] = useLazyFetch(\"http://localhost:8080/posts\",\n  (response) => {\n    console.log(\"response\", response);\n    setPosts(response)\n  }\n  {\n    method: \"GET\",\n    // ...other request options\n  });\n\n  if (loading) return \"Loading...\";\n\n  return (\n    <div>\n      <button onClick={getAllPosts}>Get Users</button>\n      {posts.map((item) => (\n        <p>{item.title}</p>\n      ))}\n    </div>\n  );\n};\n```\n\n## License\n\nMIT © [Ajay](LICENSE)\n\n---\n\nThis hook is created using [create-react-hook](https://github.com/hermanya/create-react-hook).\n","readmeFilename":"README.md"}