{"id":22336541,"url":"https://github.com/zhangmingfeng/egg-axios","last_synced_at":"2025-07-29T22:32:16.911Z","repository":{"id":57220315,"uuid":"129912778","full_name":"zhangmingfeng/egg-axios","owner":"zhangmingfeng","description":"egg axios plugin","archived":false,"fork":false,"pushed_at":"2020-12-04T02:09:21.000Z","size":20,"stargazers_count":19,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-22T03:06:22.342Z","etag":null,"topics":["axios","egg","egg-axios","egg-plugin","nodejs"],"latest_commit_sha":null,"homepage":null,"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/zhangmingfeng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-17T13:57:14.000Z","updated_at":"2024-07-02T04:22:36.000Z","dependencies_parsed_at":"2022-08-29T00:11:54.470Z","dependency_job_id":null,"html_url":"https://github.com/zhangmingfeng/egg-axios","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangmingfeng%2Fegg-axios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangmingfeng%2Fegg-axios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangmingfeng%2Fegg-axios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangmingfeng%2Fegg-axios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhangmingfeng","download_url":"https://codeload.github.com/zhangmingfeng/egg-axios/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227757946,"owners_count":17815485,"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":["axios","egg","egg-axios","egg-plugin","nodejs"],"created_at":"2024-12-04T06:07:09.946Z","updated_at":"2024-12-04T06:07:10.636Z","avatar_url":"https://github.com/zhangmingfeng.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# egg-axios\r\n[axios](https://github.com/axios/axios) plugin for Egg.js.\r\n\r\n\u003e NOTE: This plugin just for integrate axios into Egg.js, more documentation please visit https://github.com/axios/axios.\r\n\r\n# Install\r\n\r\n```bash\r\n$ npm i --save egg-axios\r\n```\r\n\r\n## Usage \u0026 configuration\r\n\r\n- `config.default.js`\r\n\r\n```js\r\nexports.http = {\r\n  headers: {\r\n     common: {\r\n        'Content-Type': 'application/json; charset=UTF-8'\r\n       }\r\n  },\r\n timeout: 10000\r\n};\r\n```\r\n\r\n- `config/plugin.js`\r\n\r\n``` js\r\nexports.http = {\r\n  enable: true,\r\n  package: 'egg-axios'\r\n}\r\n```\r\n\r\n### example\r\n\r\n```js\r\n// controller.js or service.js\r\n// with promise\r\nthis.ctx.http.get('/user', {id: 123}).then((data)=\u003e{ // ==\u003e /user?id=123\r\n    // data is only remote server response data\r\n    console.log(data);\r\n}).catch((err)=\u003e{\r\n    console.error(err);\r\n});\r\nthis.ctx.http.get('/user/:id', {id: 123}).then((data)=\u003e{ // ==\u003e /user/123\r\n    // data is only remote server response data\r\n    console.log(data);\r\n}).catch((err)=\u003e{\r\n    console.error(err);\r\n});\r\n```\r\n```js\r\nthis.ctx.http.post('/post', {postId: 123}).then((data)=\u003e{\r\n    // data is only remote server response data\r\n    console.log(data);\r\n}).catch((err)=\u003e{\r\n    console.error(err);\r\n});\r\n```\r\n```js\r\n// with await/async\r\ntry {\r\n    const data = await this.ctx.http.get('/user', {id: 123});\r\n    console.log(data);\r\n} catch (e) {\r\n    console.error(e)\r\n}\r\n```\r\n```js\r\ntry {\r\n    const data = await this.ctx.http.post('/post', {postId: 123});\r\n    console.log(data);\r\n} catch (e) {\r\n    console.error(e)\r\n}\r\n```\r\nmore example please visit https://github.com/axios/axios.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhangmingfeng%2Fegg-axios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhangmingfeng%2Fegg-axios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhangmingfeng%2Fegg-axios/lists"}