{"bugs":{"url":"https://github.com/attojs/vue-request/issues"},"dist":{"shasum":"65ba171e4cca2b882d00f90ff49b55c98681db36","tarball":"https://registry.npmjs.org/vue-request/-/vue-request-1.2.5.tgz","fileCount":34,"integrity":"sha512-qKBP+BFjolKhKnuVtuLJARNw4y+d+2vayjPddtt7HRrjG3VporPuAZzl6CmlNb6MMkHnM5CGcaME2FL6linUGA==","signatures":[{"sig":"MEQCIE0oLIwKMl2Vp7goI7zfcLp+8LVGLPUBMia4V5Ef0XxYAiB+FoGwByBoBk5y6MUM1GIkmyC7VUGFTAdx13GuUnrr1w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":125237},"main":"dist/index.cjs.js","name":"vue-request","husky":{"hooks":{"pre-push":"yarn test --coverage=false","commit-msg":"commitlint -x @commitlint/config-conventional -e $HUSKY_GIT_PARAMS","pre-commit":"node ./scripts/preCommit.js && lint-staged"}},"types":"dist/types/index.d.ts","unpkg":"dist/vue-request.min.js","module":"dist/index.es.js","readme":"English | [简体中文](README-zh_CN.md)\n\n<p align=\"center\">\n  <a href=\"https://www.attojs.org\">\n    <img\n      width=\"150\"\n      src=\"https://raw.githubusercontent.com/AttoJS/art/master/vue-request-logo.png\"\n      alt=\"VueRequest logo\"\n    />\n  </a>\n</p>\n<h1 align=\"center\">VueRequest</h1>\n<div align=\"center\">\n  <p align=\"center\">⚡️ Vue 3 composition API for data fetching, supports SWR, polling, error retry, cache request, pagination, etc.</p>\n  <a href=\"https://codecov.io/github/attojs/vue-request?branch=v1\">\n    <img\n      src=\"https://img.shields.io/codecov/c/github/attojs/vue-request?token=NW2XVQWGPP\"\n      alt=\"Coverage Status\"\n    />\n  </a>\n  <a href=\"https://www.npmjs.com/package/vue-request/v/v1\">\n    <img src=\"https://img.shields.io/bundlephobia/minzip/vue-request/v1\" alt=\"Size\" />\n  </a>\n  <a href=\"https://www.npmjs.com/package/vue-request/v/v1\">\n    <img src=\"https://img.shields.io/npm/v/vue-request/v1\" alt=\"Version\" />\n  </a>\n  <a href=\"https://www.npmjs.com/package/vue-request/v/v1\">\n    <img src=\"https://img.shields.io/github/languages/top/attojs/vue-request\" alt=\"Languages\" />\n  </a>\n  <a href=\"https://www.npmjs.com/package/vue-request/v/v1\">\n    <img src=\"https://img.shields.io/npm/l/vue-request\" alt=\"License\" />\n  </a>\n  <a href=\"https://github.com/AttoJS/vue-request/stargazers\">\n    <img src=\"https://img.shields.io/github/stars/attojs/vue-request\" alt=\"Star\" />\n  </a>\n  <a href=\"https://www.npmjs.com/package/vue-request/v/v1\">\n    <img src=\"https://img.shields.io/npm/dm/vue-request\" alt=\"Download\" />\n  </a>\n</div>\n\n## Status\n\n**The v1 version will not add new functions in the future, and will only maintain the bugs that appear. To experience the latest features, please switch to the v2 version.**\n\n## Why VueRequest\n\nIn the past projects, they were often confused by repeated implementations such as the management of the loading state, the requested throttling and debounce, the caching of request data, and pagination. Whenever we start a new project, we have to manually deal with the above problems, which will be a repetitive work, but also to ensure that the team is consistent.\n\nVueRequest aims to provide developers with a convenient and fast way to manage the state of the request API. In the development, save repetitive work, and it can be used only with a simple configuration, focusing on the core of the development project.\n\n## Features\n\n- 🚀 &nbsp;All data is reactive\n- 🔄 &nbsp;Interval polling\n- 🤖 &nbsp;Automatic error retry\n- 🗄 &nbsp;Built-in cache\n- 💧 &nbsp;Throttle and Debounce\n- ⚙️ &nbsp;Powerful pagination extension and load more extensions\n- 📠 &nbsp;Written in TypeScript\n- ⚡️ &nbsp;Compatible with Vite\n- 🍃 &nbsp;Lightweight\n- 📦 &nbsp;Out of the box\n\n## Documentation\n\n- [English](https://www.attojs.org/)\n- [中文文档](https://www.attojs.com/)\n\n## Install\n\nYou can install VueRequest with [NPM](https://www.npmjs.com/), [YARN](https://yarnpkg.com/), or a `<script>` via [unpkg.com](https://unpkg.com/)\n\n### NPM\n\n```sh\nnpm install vue-request@v1\n# or\nyarn add vue-request@v1\n```\n\n### CDN\n\n> For production, we recommend linking to a specific version number and build to avoid unexpected breakage from newer versions.\n\n```html\n<script src=\"https://unpkg.com/vue-request@v1/dist/vue-request.min.js\"></script>\n```\n\nOnce you've added this you will have access to the `window.VueRequest` object and its exports.\n\n## Usage\n\n```vue\n<template>\n  <div>\n    <div v-if=\"loading\">loading...</div>\n    <div v-if=\"error\">failed to fetch</div>\n    <div v-if=\"data\">Hey! {{ data }}</div>\n  </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue';\nexport default defineComponent({\n  setup() {\n    const { data, loading, error } = useRequest(service);\n\n    return {\n      data,\n      loading,\n      error,\n    };\n  },\n});\n</script>\n```\n\nIn this example, `useRequest` accepts a `service` function. `service` is a asynchronous function. In other words, you can use **axios** to fetch data and return a **Promise**. More specific instructions can be viewed in [document](https://www.attojs.org/guide/documentation/dataFetching.html).\n\n`useRequest` also return 3 values: `data`, `loading` and `error`. When the request is not yet finished, data will be `undefined` and `loading` will be `true`. And when we get a response, it sets data and error based on the result of service and rerenders the component. This is because `data` and `error` are [Reactivity(Refs)](https://v3.vuejs.org/guide/reactivity-fundamentals.html), and their values will be set by the service response.\n\n## Some of the coolest features:\n\nVueRequest has many features, such as error retry, cache, pagination, throttle, debounce..., here are two cool features\n\n### 1.Refresh On Focus\n\nSometimes, you need to ensure data consistency between multiple browser windows; or when the user's computer is reactivated in the dormant state, the page data needs to be synchronized to the latest state. `refreshOnWindowFocus` may save you a lot of code. [Click here to go to the document](https://www.attojs.org/guide/documentation/refreshOnWindowFocus.html)\n\n```ts\nconst { data, error, run } = useRequest(getUserInfo, {\n  refreshOnWindowFocus: true,\n  refocusTimespan: 1000, // refresh interval 1s\n});\n```\n\n![vue-request](https://z3.ax1x.com/2021/09/10/hXAs8s.gif)\n\n### 2.Polling Data\n\nSometimes, you want to ensure that data is synchronized and updated between multiple devices. At this time, we can use the `pollingInterval` provided by us to periodically re-request the request API, so that the data consistency between multiple devices can be guaranteed. When the user modifies the data, the two windows will be updated simultaneously in real time. [Click here to go to the document](https://www.attojs.org/guide/documentation/polling.htm)\n\n```ts\nconst { data, error, run } = useRequest(getUserInfo, {\n  pollingInterval: 1000, // polling interval 1s\n});\n```\n\n![vue-request](https://z3.ax1x.com/2021/09/10/hXAy2n.gif)\n\n## TODO List\n\nIf you have any cool features, please submit an issue for discussion\n\n- [x] Support Vue 2. see [master](https://github.com/AttoJS/vue-request/tree/master) branch\n- [x] Documentation\n- [x] Pagination\n- [x] Load More\n\n## Thanks\n\nThank them for inspiring us.\n\n- [vercel/swr](https://github.com/vercel/swr)\n- [alibaba/hooks](https://ahooks.js.org/hooks/async#userequest)\n\n## License\n\n[MIT License](https://github.com/AttoJS/vue-request/blob/master/LICENSE) © 2020-present [AttoJS](https://github.com/AttoJS)\n","license":"MIT","scripts":{"dev":"yarn vite ./example","lint":"eslint -c ./.eslintrc.js './{src,scripts,build}/**/*.{js,ts,tsx}'","test":"jest --coverage","vite":"vite --config ./build/vite.config.ts","build":"yarn clean && rollup --config ./build/rollup.config.js","clean":"rimraf dist/*","format":"prettier -w '**/*.ts?(x)'","release":"yarn build && yarn publishing","changelog":"standard-version && standard-version -i CHANGELOG.zh-CN.md -o CHANGELOG.zh-CN.md","publishing":"np"},"_npmUser":{"name":"john60676","email":"john60676@qq.com"},"homepage":"https://www.attojs.org/","keywords":["vue","vue3","swr","request","http","fetch","composition-api","axios","vue-request","vue request"],"repository":{"url":"https://github.com/attojs/vue-request.git","type":"git"},"description":"Vue 3 composition API for data fetching, supports SWR, polling, error retry, cache request, pagination and other cool features.","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2020 AttoJS\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","lint-staged":{"package.json":"sort-package-json","*.{js,jsx,ts,tsx}":["eslint --fix"]},"maintainers":[{"name":"bennyyu","email":"bennyyu0429@gmail.com"},{"name":"john60676","email":"john60676@qq.com"}],"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"np":"^7.0.0","vue":"^3.0.2","jest":"^26.6.0","vite":"^2.1.5","axios":"^0.21.1","husky":"^4.3.0","eslint":"^7.14.0","mockjs":"^1.1.0","rimraf":"^3.0.2","rollup":"^2.33.1","ts-jest":"^26.4.1","prettier":"^2.2.0","babel-jest":"^26.6.0","fetch-mock":"^9.10.7","node-fetch":"^2.6.1","simple-git":"^3.3.0","typescript":"^4.0.5","@babel/core":"^7.12.3","@types/jest":"^26.0.15","lint-staged":"^10.5.2","@types/mockjs":"^1.0.3","@commitlint/cli":"^11.0.0","@vue/test-utils":"^2.0.0-beta.8","standard-version":"^9.1.1","@babel/preset-env":"^7.12.1","@vue/compiler-sfc":"^3.0.6","eslint-plugin-vue":"^7.0.0-0","sort-package-json":"^1.50.0","@vitejs/plugin-vue":"^1.2.1","@rollup/plugin-babel":"^5.2.1","rollup-plugin-terser":"^7.0.2","@vue/babel-plugin-jsx":"^1.0.0-rc.3","@babel/runtime-corejs3":"^7.12.5","@vitejs/plugin-vue-jsx":"^1.1.3","eslint-config-prettier":"^6.15.0","eslint-plugin-prettier":"^3.1.4","@rollup/plugin-commonjs":"^16.0.0","@typescript-eslint/parser":"^4.8.2","rollup-plugin-typescript2":"^0.29.0","@rollup/plugin-node-resolve":"^10.0.0","jest-environment-jsdom-global":"^2.0.4","@babel/plugin-transform-runtime":"^7.12.1","@commitlint/config-conventional":"^11.0.0","@typescript-eslint/eslint-plugin":"^4.8.2","eslint-plugin-simple-import-sort":"^7.0.0","@babel/plugin-proposal-nullish-coalescing-operator":"^7.14.5"},"peerDependencies":{"vue":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/vue-request_1.2.5_1685623917934_0.09215169027574754","host":"s3://npm-registry-packages"},"_id":"vue-request@1.2.5","version":"1.2.5"}