{"id":15566910,"url":"https://github.com/msidolphin/vue-api-creator","last_synced_at":"2025-04-23T23:47:38.439Z","repository":{"id":57394473,"uuid":"183353178","full_name":"msidolphin/vue-api-creator","owner":"msidolphin","description":"An api manager bases on axios","archived":false,"fork":false,"pushed_at":"2019-12-18T07:53:47.000Z","size":89,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-18T23:24:16.947Z","etag":null,"topics":["ajax","api-manager","axios","http","vuejs"],"latest_commit_sha":null,"homepage":"","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/msidolphin.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":"2019-04-25T03:58:29.000Z","updated_at":"2025-03-02T14:21:35.000Z","dependencies_parsed_at":"2022-09-09T16:51:37.182Z","dependency_job_id":null,"html_url":"https://github.com/msidolphin/vue-api-creator","commit_stats":null,"previous_names":["msidolphin/vue-api-manager"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msidolphin%2Fvue-api-creator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msidolphin%2Fvue-api-creator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msidolphin%2Fvue-api-creator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msidolphin%2Fvue-api-creator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msidolphin","download_url":"https://codeload.github.com/msidolphin/vue-api-creator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250496991,"owners_count":21440231,"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","api-manager","axios","http","vuejs"],"created_at":"2024-10-02T17:08:31.101Z","updated_at":"2025-04-23T23:47:38.415Z","avatar_url":"https://github.com/msidolphin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vue-api-creator\n\n[![Build Status](https://travis-ci.org/msidolphin/vue-api-creator.svg?branch=master)](https://travis-ci.org/msidolphin/vue-api-creator)\n[![Coverage Status](https://coveralls.io/repos/github/msidolphin/vue-api-creator/badge.svg?branch=master)](https://coveralls.io/github/msidolphin/vue-api-creator?branch=master)\n[![codebeat badge](https://codebeat.co/badges/11889be9-13b5-4ba4-b401-81c472d1d5d6)](https://codebeat.co/projects/github-com-msidolphin-vue-api-creator-master)\n\n\u003e An api manager bases on axios\n\n[中文文档](./README_CN.md)\n\n## Usage\n\n### Install\n\n```bash\nnpm install vue-api-creator -S\n```\n\n```js\nimport api from './api'\nimport ApiCreator from 'vue-api-creator'\n\nVue.use(ApiCreator, {\n  baseURL: '/baseURL'\n  modules: api,\n  // Response fails if response status is in this list\n  permanentErrors: [404, 415, 500, 501, 429],\n  beforeRequest (options) {\n    console.log(options)\n  },\n  afterRequest (res) {\n    console.log(res)\n  },\n  onError (err) {\n    if (err.isInternalError) {\n      console.log('An exception has occurred on your network')\n    } else {\n      console.log('An error response from server')\n    }\n  },\n  mock: 'https://www.xxxx.com'\n})\n```\n\n### Use\n```js\nexport default {\n    created () {\n        this.$api('app/list').then(res =\u003e {\n            // ....\n        }).catch(err =\u003e {\n            // ....\n        })\n    }\n}\n```\n\n### Api directory\n\n```js\n├──  api\n│    │── app\n│    │    ├── index.js\n│    └── index.js   \n```\n\n#### app/index.js\n```js\nexport default {\n    BASE_URL: '/sys/app',\n    api: [\n      {\n        name: 'list',\n        desc: 'get apps',\n        method: 'GET',\n        path: 'list',\n        mock: true // enable mock\n      }\n    ]\n}\n```\n\n#### api/index.js\n```js\nimport app from './app'\n\nexport default {\n    app\n}\n```\n\n### Server Response Structure\n\nYour server response body shoule be like this:\n\n```\n{\n  code: Number, // status code\n  success: Boolean, // whether the response was successful \n  msg: String, // response message\n  data: \u003cT\u003e // response data\n}\n```\n\n### Configuration\n\n#### ApiCreator config\n\n* `baseURL`: The base URL of the request. (String or Function)\n* `modules`: Api modules.\n* `axios`: axios instance.\n* `enableEncodeURIComponent`: encodes characters using EncodeURIComponent.\n* `permanentErrors`: Response fails if response status is in this list, default: [404, 415, 500, 501, 429].\n* `beforeRequest`: Called before the request is sent.\n* `afterRequest`: Called after the request was received.\n* `onError`: An error occurred during send request or server response, eg: status code in permanentErrors, the request was made but no response was received...\n* `mock`: The base URL of the mock server.\n\n#### Api config\n\n* `name`: It is api's name.\n* `desc`: The description of the api.\n* `method`: The request method to be used when making the request.\n* `path`: It is the server URL that will be used for the request.\n* `mock`: Enable mock to the request.\n* `params`: query params (Array or Boolean). eg: params: ['id', 'name'] =\u003e /api/xxxx?id=1\u0026name=2\n* `body`: body params (Array or Boolean). eg: body: ['ids', 'names'] =\u003e {ids: [1], names: ['a', 'b']}\n* `responseType`: response type. accepted values: ['', 'arraybuffer', 'blob', 'document', 'json', 'text']. default: json\n\n## License\n[MIT](http://opensource.org/licenses/MIT)\n\nCopyright © 2019, msidolphin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsidolphin%2Fvue-api-creator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsidolphin%2Fvue-api-creator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsidolphin%2Fvue-api-creator/lists"}