{"id":16384720,"url":"https://github.com/saber2pr/request","last_synced_at":"2025-07-11T01:10:20.246Z","repository":{"id":108571481,"uuid":"184696741","full_name":"Saber2pr/request","owner":"Saber2pr","description":":stars: A HTTP Request library.","archived":false,"fork":false,"pushed_at":"2020-06-05T08:59:38.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-06T06:07:56.294Z","etag":null,"topics":["ajax","http","xhr"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Saber2pr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-05-03T04:06:35.000Z","updated_at":"2020-06-05T08:59:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"ce1c530f-7b13-43b6-8202-046574618d45","html_url":"https://github.com/Saber2pr/request","commit_stats":{"total_commits":29,"total_committers":2,"mean_commits":14.5,"dds":0.03448275862068961,"last_synced_commit":"b6940cdf2c592d29bda8fee3a1b30b49545d964b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Saber2pr/request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Frequest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Frequest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Frequest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Frequest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Saber2pr","download_url":"https://codeload.github.com/Saber2pr/request/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Frequest/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264703248,"owners_count":23651933,"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":["ajax","http","xhr"],"created_at":"2024-10-11T04:12:11.639Z","updated_at":"2025-07-11T01:10:20.215Z","avatar_url":"https://github.com/Saber2pr.png","language":"TypeScript","readme":"# @saber2pr/request\n\n[![npm](https://img.shields.io/npm/v/@saber2pr/request.svg?color=blue)](https://www.npmjs.com/package/@saber2pr/request)\n\n\u003e 提供全局拦截器配置\n\n# 为什么？\n\n已经有 axios...\n\nqwq\n\naxios 在使用 rollup 打包时会发生错误，无法处理 http 依赖(别和我说 webpack :(\n\n```bash\nnpm install @saber2pr/request\n```\n\n# API\n\n```ts\nnew Request(baseConfig)\n```\n\n## 常用请求\n\n1. new Request().get(url, config)\n\n2. new Request().post(url, config)\n\n3. new Request().put(url, config)\n\n4. new Request().delete(url, config)\n\n## 自定义请求\n\nnew Request().fetch\n\n## 拦截器\n\n1. new Request().interceptors\n2. new Request().interceptors.request\n3. new Request().interceptors.request.use\n4. new Request().interceptors.requestInterceptors\n5. new Request().interceptors.response\n6. new Request().interceptors.response.use\n7. new Request().interceptors.responseInterceptors\n\n```ts\nimport axios from \"@saber2pr/request\" // const axios = new Request()\n\naxios.interceptors.request.use(config =\u003e {\n  /** code **/\n\n  config.headers.Authorization =\n    \"Basic \" + Base64.encode(`${username}:${password}`)\n\n  return config\n})\n\naxios.interceptors.response.use(res =\u003e {\n  switch (res.status) {\n    case 200:\n      return res\n\n    case 401:\n      push(\"/login\")\n      break\n\n    default:\n      push(\"/error\")\n  }\n})\n```\n\n### 还需要说么。。\n\n使用 typescript 编码，不需要文档！qwq\n\n```ts\nnpm start\n\nnpm run dev\n\nnpm run serve\n```\n\n# Author\n\n\u003e saber2pr\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaber2pr%2Frequest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaber2pr%2Frequest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaber2pr%2Frequest/lists"}