All Projects → christianmalek → Vuex Rest Api

christianmalek / Vuex Rest Api

Licence: mit
A utility to simplify the use of REST APIs with Vuex

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vuex Rest Api

Smoke
💨 Simple yet powerful file-based mock server with recording abilities
Stars: ✭ 142 (-61.1%)
Mutual labels:  api, rest, hacktoberfest
Horaires Ratp Api
Webservice pour les horaires et trafic RATP en temps réel
Stars: ✭ 232 (-36.44%)
Mutual labels:  api, rest, hacktoberfest
Core
The server component of API Platform: hypermedia and GraphQL APIs in minutes
Stars: ✭ 2,004 (+449.04%)
Mutual labels:  api, rest, hacktoberfest
Falcon
The no-nonsense REST API and microservices framework for Python developers, with a focus on reliability, correctness, and performance at scale.
Stars: ✭ 8,654 (+2270.96%)
Mutual labels:  api, rest, hacktoberfest
Loopback Next
LoopBack makes it easy to build modern API applications that require complex integrations.
Stars: ✭ 3,972 (+988.22%)
Mutual labels:  api, rest, hacktoberfest
Ratp Api Rest
This project turnkey is distributed as a middleware to expose RATP realtime data as REST resources
Stars: ✭ 68 (-81.37%)
Mutual labels:  api, rest, hacktoberfest
Bookmarks.dev
Bookmarks and Code Snippets Manager for Developers & Co
Stars: ✭ 218 (-40.27%)
Mutual labels:  api, rest, hacktoberfest
Axios Rest
A simple axios wrapper to make rest api call delightful
Stars: ✭ 41 (-88.77%)
Mutual labels:  api, rest, axios
Product Ei
An open source, a high-performance hybrid integration platform that allows developers quick integration with any application, data, or system.
Stars: ✭ 277 (-24.11%)
Mutual labels:  api, rest, middleware
Vue Home
🏠 A simple project(Vue Community SPA) which bases on vue+vue-cli+vue-router+axios+ scss.
Stars: ✭ 256 (-29.86%)
Mutual labels:  axios, vuex, vue2
Openapi Generator
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
Stars: ✭ 10,634 (+2813.42%)
Mutual labels:  api, rest, hacktoberfest
Vulcain
Fast and idiomatic client-driven REST APIs.
Stars: ✭ 3,190 (+773.97%)
Mutual labels:  api, rest, hacktoberfest
Githubapi
Swift implementation of Github REST API v3
Stars: ✭ 55 (-84.93%)
Mutual labels:  api, rest, hacktoberfest
Strapi
🚀 Open source Node.js Headless CMS to easily build customisable APIs
Stars: ✭ 41,786 (+11348.22%)
Mutual labels:  api, rest, hacktoberfest
Json Api Dart
JSON:API client for Dart/Flutter
Stars: ✭ 53 (-85.48%)
Mutual labels:  api, rest, hacktoberfest
Symfony Flex Backend
Symfony Flex REST API template project
Stars: ✭ 214 (-41.37%)
Mutual labels:  api, rest, hacktoberfest
Apicache
Simple API-caching middleware for Express/Node.
Stars: ✭ 957 (+162.19%)
Mutual labels:  api, rest, middleware
Axios Module
Secure and easy axios integration with Nuxt.js
Stars: ✭ 998 (+173.42%)
Mutual labels:  api, hacktoberfest, axios
Mockoon
Mockoon is the easiest and quickest way to run mock APIs locally. No remote deployment, no account required, open source.
Stars: ✭ 3,448 (+844.66%)
Mutual labels:  api, rest, hacktoberfest
Vue Testing Examples
Advanced testing with vuejs. When you need to go beyond Getting started section and see some real world example with everything that proper tests should have.
Stars: ✭ 288 (-21.1%)
Mutual labels:  axios, vuex, vue2

vuex-rest-api

npm npm

A Helper utility to simplify the usage of REST APIs with Vuex 2. Uses the popular HTTP client axios for requests. Works with websanova/vue-auth.

What is this good for

If you want to connect a REST API with Vuex you'll find that there are a few repetitive steps. You need to request the data from the api (with an action) and set the state (via a mutation). This utility (for the sake of brevity called Vapi in the README) helps in creating the store by setting up the state, mutations and actions with a easy to follow pattern.

It is not a middleware.

It's just a helper utility to help prepraring the store object for you. If there's something you don't like just overwrite the property.

Installation

npm install vuex-rest-api

Some notes: This readme assumes that you're using at least ES2015.

Steps

  1. Import vuex-rest-api (I called it Vapi).
  2. Create a Vapi instance.
    At least you have to set the base URL of the API you're requesting from. You can also define the default state. If you don't define a default state from a property it will default to null. In the example
  3. Create the actions.
    Each action represents a Vuex action. If it will be called (property action), it requests a specific API endpoint (property path) and sets the related property named property to the response's payload.
  4. Create the store object
  5. Pass it to Vuex. Continue reading here to know how to call the actions.
// store.js

import Vuex from "vuex"
import Vue from "vue"
// Step 1
import Vapi from "vuex-rest-api"

Vue.use(Vuex)

// Step 2
const posts = new Vapi({
  baseURL: "https://jsonplaceholder.typicode.com",
    state: {
      posts: []
    }
  })
  // Step 3
  .get({
    action: "getPost",
    property: "post",
    path: ({ id }) => `/posts/${id}`
  })
  .get({
    action: "listPosts",
    property: "posts",
    path: "/posts"
  })
  .post({
    action: "updatePost",
    property: "post",
    path: ({ id }) => `/posts/${id}`
  })
  // Step 4
  .getStore()

// Step 5
export const store = new Vuex.Store(posts)

Minimal example

Yep, here: https://codesandbox.io/s/8l0m8qk0q0

API and further documentation

The docs are now available under http://vuex-rest-api.org

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].