{"id":27943535,"url":"https://github.com/zadigo/vue-requests-store","last_synced_at":"2026-04-25T23:37:26.030Z","repository":{"id":112577209,"uuid":"463837830","full_name":"Zadigo/vue-requests-store","owner":"Zadigo","description":"A store which purpose is to keep all the APIs for an app in one place","archived":false,"fork":false,"pushed_at":"2022-02-26T12:23:07.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T12:12:28.782Z","etag":null,"topics":["vue","vue-plugin","vue-plugins","vuejs3"],"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/Zadigo.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-02-26T11:48:19.000Z","updated_at":"2022-02-26T11:56:34.000Z","dependencies_parsed_at":"2023-03-15T15:30:36.905Z","dependency_job_id":null,"html_url":"https://github.com/Zadigo/vue-requests-store","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Zadigo/vue-requests-store","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zadigo%2Fvue-requests-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zadigo%2Fvue-requests-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zadigo%2Fvue-requests-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zadigo%2Fvue-requests-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zadigo","download_url":"https://codeload.github.com/Zadigo/vue-requests-store/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zadigo%2Fvue-requests-store/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32280981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["vue","vue-plugin","vue-plugins","vuejs3"],"created_at":"2025-05-07T12:12:27.312Z","updated_at":"2026-04-25T23:37:26.025Z","avatar_url":"https://github.com/Zadigo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vue Requests Store\n\nA Vue project can contain many different APIs from different files in your project. To resolve this issue, the Vue Requests Store centralize your APIs in one place which make them much easier to call in your templates.\n\n## How to install\n\nInstalling VueRequestStore is very easy. You need to create a plugin file in your plugins folder in src and do the following:\n\n```javascript\nimport { createApiStore } from './vue-api'\nimport myAxios from './my-axios'\n\nvar api = createApiStore(null, {\n  // Rest of code goes there\n})\n```\n`createApiStore` takes two parameters: `client`, `options`. The client is the custom one that you intend to use in your project e.g. axios and the options are a list of requests to be stored in the store. Once you defined your client as so somewhere in your app:\n\n```javascript\nimport axios from 'axios'\n\nconst client = axios.create({\n    baseURL: 'https://jsonplaceholder.typicode.com/',\n    timeout: 60 * 1000,\n    headers: { 'Content-Type': 'application/json' },\n    withCredentials: false\n})\n\nwindow.axios = client\n\nexport default client\n```\nThe previous code becomes:\n\n```javascript\nimport { createApiStore } from './vue-api'\nimport client from './my-custom-client'\n\nvar api = createApiStore(client, {\n  // Rest of code goes there\n})\n```\n\n## Registering your requests\n\nThe `options` parameter of `createApiStore` requires on root element `requests` which is an array of dicts which themselves require two main keys: `name` and `action`.\n\n```javascript\nvar api = createApiStore(client, {\n  requests: [\n    {\n      name: 'todos',\n      action: (client, params) =\u003e {\n        method: 'get',\n        url: '/todos'\n      }\n    }\n  ]\n})\n```\nThe action function takes two parameters: `client` and `params`. The client is the one you initially passed in `createApiStore` that will be used to make the calls. `params` are simply additional parameters passed from your template in order to complete the url for the call.\n\n## Examples\n\n### Sending a request without parameters\n\n```html\n\u003cscript\u003e\nexport default {\n  name: 'SomeComponent'\n  methods: {\n    testApi () {\n      this.$api('todos')\n      .then((response) =\u003e {\n        // Rest of code\n      })\n      .catch((error) =\u003e {\n        // Rest of code\n      })\n    }\n  }\n}\n\u003c/script\u003e\n```\n\n### Sending a request with parameters\n\n```html\n\u003cscript\u003e\nexport default {\n  name: 'SomeComponent'\n  methods: {\n    testApi () {\n      this.$api('todos', { id: 1 })\n      .then((response) =\u003e {\n        // Rest of code\n      })\n      .catch((error) =\u003e {\n        // Rest of code\n      })\n    }\n  }\n}\n\u003c/script\u003e\n```\n\n```javascript\nvar api = createApiStore(client, {\n  requests: [\n    {\n      name: 'todos',\n      action: (client, params) =\u003e {\n        method: 'get',\n        url: '/todos/${params.id}'\n      }\n    }\n  ]\n})\n```\n\n```javascript\nvar api = createApiStore(client, {\n  requests: [\n    {\n      name: 'todos',\n      action: (client, params) =\u003e {\n        method: 'get',\n        url: '/posts/1/comments',\n        params: params\n      }\n    }\n  ]\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzadigo%2Fvue-requests-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzadigo%2Fvue-requests-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzadigo%2Fvue-requests-store/lists"}