{"id":18387332,"url":"https://github.com/terryz/http-data-request","last_synced_at":"2026-02-13T20:02:13.261Z","repository":{"id":247907341,"uuid":"827197434","full_name":"TerryZ/http-data-request","owner":"TerryZ","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-10T05:08:22.000Z","size":253,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-04-07T00:34:06.521Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://terryz.github.io/docs-utils/http-data-request","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TerryZ.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG-CN.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-11T07:28:14.000Z","updated_at":"2025-03-10T05:05:58.000Z","dependencies_parsed_at":"2024-07-11T08:51:17.241Z","dependency_job_id":"f7b1719b-4fc7-4eff-8b3f-880b4fce3152","html_url":"https://github.com/TerryZ/http-data-request","commit_stats":null,"previous_names":["terryz/http-data-request"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/TerryZ/http-data-request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TerryZ%2Fhttp-data-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TerryZ%2Fhttp-data-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TerryZ%2Fhttp-data-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TerryZ%2Fhttp-data-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TerryZ","download_url":"https://codeload.github.com/TerryZ/http-data-request/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TerryZ%2Fhttp-data-request/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261838177,"owners_count":23217591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T01:25:44.122Z","updated_at":"2026-02-13T20:02:08.220Z","avatar_url":"https://github.com/TerryZ.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# http-data-request\n\nCreate customized data request methods for web projects\n\n[![CircleCI](https://circleci.com/gh/TerryZ/http-data-request/tree/main.svg?style=svg)](https://circleci.com/gh/TerryZ/http-data-request/tree/main)\n[![code coverage](https://codecov.io/gh/TerryZ/http-data-request/branch/main/graph/badge.svg)](https://codecov.io/gh/TerryZ/http-data-request)\n[![npm version](https://img.shields.io/npm/v/http-data-request.svg)](https://www.npmjs.com/package/http-data-request)\n[![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://mit-license.org/)\n[![npm](https://img.shields.io/npm/dy/http-data-request.svg)](https://www.npmjs.com/package/http-data-request)\n\n## Features\n\n- Automatically save and apply authorization tokens\n- Unified handling of exception information\n- Customizable status code\n- Customizable authorization data node\n- Provides quick access functions for each request method\n- Provides a function to cancel all current requests\n\n## Examples and Documentation\n\nDocumentation and examples please visit below sites\n\n- [Github pages](https://terryz.github.io/docs-utils/http-data-request/)\n\n## Installation\n\n```sh\n# npm\nnpm i http-data-request\n# yarn\nyarn add http-data-request\n# pnpm\npnpm add http-data-request\n```\n\n### Setup to your project\n\nAdd a file in the project, such as `/src/config/http/index.js`, to set the global configuration of `http-data-request` and export various functional functions\n\n```js\nimport { useHttpDataRequest } from 'http-data-request'\n\nconst options = {\n  baseUrl: 'https://example.com/api',\n}\n\nexport const {\n  http, get, post, put, patch, del, cancel\n} = useHttpDataRequest(options)\n```\n\nIn the Vite configuration file `vite.config.js`, set an alias for the project installation module directory for http\n\n```js\nimport { fileURLToPath, URL } from 'node:url'\nimport { resolve } from 'path'\nimport { defineConfig } from 'vite'\n\nexport default defineConfig({\n  resolve: {\n    alias: {\n      '@': fileURLToPath(new URL('./src', import.meta.url)),\n      '@api': fileURLToPath(new URL('./src/api', import.meta.url)),\n      '@http': fileURLToPath(new URL('./src/config/http', import.meta.url))\n    }\n  },\n  ...\n})\n```\n\n## Usage\n\nDefine data request methods for business\n\n```js\n// /src/api/user.js\nimport { get, post } from '@http'\n\nexport function getUser (userId) {\n  return get(`/user/${userId}`)\n}\n```\n\nUse in component\n\n```vue\n\u003ctemplate\u003e\n  \u003cdiv\u003e\n    \u003cdiv\u003eUser name: {{ user.name }}\u003c/div\u003e\n    \u003cdiv\u003eUser age: {{ user.age }}\u003c/div\u003e\n  \u003c/div\u003e\n\u003c/template\u003e\n\u003cscript setup\u003e\nimport { ref } from 'vue'\nimport { getUser } from '@api/user'\n\nconst user = ref({})\n\ngetUser(10).then(data =\u003e { user.value = data })\n\u003c/script\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterryz%2Fhttp-data-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterryz%2Fhttp-data-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterryz%2Fhttp-data-request/lists"}