Registry / devops / vuex-rest-api

vuex-rest-api

JSON →
library2.16.0jsnpmunverified

A helper utility to simplify the use of REST APIs with Vuex 2.x, using axios for HTTP requests. The current stable version is 2.16.0. It provides a fluent API to define actions, mutations, and state for Vuex stores with minimal boilerplate. Key differentiators: integrates seamlessly with Vuex 2, supports dynamic path parameters via functions, and works with websanova/vue-auth. Does not support Vuex 3+ (Vue 3). Release cadence is low; no updates since 2019.

npm install vuex-rest-api
INSTALL
IMPORT
SIG · VUEX-REST-API
V
vuex-rest-api
devopsjavascriptv2.16.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Vapi
✓ import Vapi from 'vuex-rest-api'
✗ const Vapi = require('vuex-rest-api')
Default export; CommonJS require works but is not recommended. Only ESM style is shown in docs.
default
✓ import Vapi from 'vuex-rest-api'
✗ const { Vapi } = require('vuex-rest-api')
The library exports only a default class; named destructuring from CommonJS is incorrect.
Vapi type
✓ import type Vapi from 'vuex-rest-api'
✗ import { Vapi } from 'vuex-rest-api'
When using TypeScript, import the type via the default import pattern; named import for type is not available.

Creates a Vuex store with a REST API endpoint using vuex-rest-api.

import Vuex from 'vuex' import Vue from 'vue' import Vapi from 'vuex-rest-api' Vue.use(Vuex) const posts = new Vapi({ baseURL: 'https://jsonplaceholder.typicode.com', state: { posts: [] } }) .get({ action: 'listPosts', property: 'posts', path: '/posts' }) .getStore() export const store = new Vuex.Store(posts)
Debug
Known issues
breakingVuex 3+ (Vue 3) not supported; only works with Vuex 2.x
fix
Use Vuex 2.x or migrate to alternative library like Pinia with vuex-rest-api replacements.
deprecatedNo updates since 2019; considered feature-complete but unmaintained
fix
Evaluate alternatives like vuex-smart-module or Pinia for active development.
affects: 2.x
gotchaPath functions must return string; dynamic parameters require arrow function with parentheses around params
fix
Use path: ({ id }) => '/posts/' + id instead of string interpolation with ES6 template literals (though they work too, but consistency matters).
affects: >=2.0.0
gotchaDefault state property must be defined; otherwise defaults to null which may cause mutations to set null
fix
Always define initial state for each property, e.g., state: { posts: [] }.
affects: >=1.0.0
gotchaActions must be called after store creation; dispatch is not automatically namespaced
fix
Dispatch actions as store.dispatch('listPosts') or with mapActions.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'get' of undefined
Vapi instance not properly created or imported incorrectly.
fix
Ensure import: import Vapi from 'vuex-rest-api'. Then: const v = new Vapi({baseURL: '...'}).get({...})
Uncaught Error: [vuex] unknown action type: listPosts
Action not defined in the store or typo in dispatch name.
fix
Check that you called .get({action: 'listPosts', ...}) before .getStore() and dispatch exactly 'listPosts'.
Module not found: 'vuex-rest-api'
Package not installed or missing from package.json.
fix
Run npm install vuex-rest-api
Cannot set property 'posts' of undefined
State not initialized properly; missing state definition in Vapi constructor.
fix
Add state: { posts: [] } when creating new Vapi.
Upgrade
Version history
2.16.0latest on npm
Audit
Dependencies
axiosrequiredHTTP client used for all API requests.
Agent activity
6 hits · last 30 days
node
6
Resources
vuex-rest-api — npm install vuex-rest-api · libregistry