{"id":21713886,"url":"https://github.com/cytle/ma-request","last_synced_at":"2025-10-03T23:51:04.282Z","repository":{"id":29243411,"uuid":"117407558","full_name":"cytle/ma-request","owner":"cytle","description":" 小程序请求，返回一个promise.","archived":false,"fork":false,"pushed_at":"2024-04-16T01:00:50.000Z","size":244,"stargazers_count":1,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-13T07:04:48.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/cytle.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":"2018-01-14T06:25:10.000Z","updated_at":"2019-07-15T01:47:31.000Z","dependencies_parsed_at":"2024-10-29T17:24:20.206Z","dependency_job_id":null,"html_url":"https://github.com/cytle/ma-request","commit_stats":{"total_commits":27,"total_committers":2,"mean_commits":13.5,"dds":0.03703703703703709,"last_synced_commit":"4aaf1b2c05ba669edfcc63497ebca9c7826dc18e"},"previous_names":["cytle/wxapp-request"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/cytle/ma-request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cytle%2Fma-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cytle%2Fma-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cytle%2Fma-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cytle%2Fma-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cytle","download_url":"https://codeload.github.com/cytle/ma-request/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cytle%2Fma-request/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261483554,"owners_count":23165405,"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-26T00:28:25.816Z","updated_at":"2025-10-03T23:50:59.250Z","avatar_url":"https://github.com/cytle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ma-request\n\n小程序请求，返回一个`promise`.\n\n## Usage\n\n```js\nimport request from 'ma-request';\n\n// 基本用法仅为示例，并非真实的接口地址\nrequest('test.php', {\n  method: 'POST', // default GET\n  data: {\n    x: '',\n    y: ''\n  },\n  headers: {\n    'User-Agent': 'Request-Promise'\n  },\n})\n  .then((data) =\u003e {\n    console.log(data);\n  }, (res) =\u003e {\n    console.log(res);\n  });\n```\n\n### request\n\n```js\nasync function demo() {\n  const res1 = await request.get({\n    url: 'test.php',\n  });\n  const res2 = await request.get('test.php'); // 等同上面\n\n  // 除get外还有options, head, post, put, delete, trace, connect\n  const res3 = await request.post('test.php', {\n    data: { x: '' },\n  });\n}\n```\n\n### setGlobalHooks(hooks) 设置全局钩子\n\n```js\nsetGlobalHooks({\n  before(options) {\n    // 拦截请求，最后需要返回一个promise\n  },\n  success(res, options) {\n    // 请求成功，可以处理结果，最后需要返回一个promise\n  },\n  fail(res, options) {},\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcytle%2Fma-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcytle%2Fma-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcytle%2Fma-request/lists"}