Skip to content

Instantly share code, notes, and snippets.

@tajidyakub
Last active July 23, 2023 11:33
Show Gist options
  • Save tajidyakub/083ef732bb5a2b65c9802a38569f438c to your computer and use it in GitHub Desktop.
Save tajidyakub/083ef732bb5a2b65c9802a38569f438c to your computer and use it in GitHub Desktop.
Memanfaatkan feathers-vuex untuk melakukan integrasi data antara feathers supplied dengan local store menggunakan Vuex.
import feathers from '@feathersjs/feathers'
import socketio from '@feathersjs/socketio-client'
import auth from '@feathersjs/authentication-client'
import io from 'socket.io-client'
const socket = io('http://localhost:4937', { transports: ['websocket'] })
const Api = feathers()
.configure(socketio(socket))
.configure(auth({ storage: window.localStorage }))
export default Api

Implementasi feathers-vuex

Instal paket yang dibutuhkan untuk melakukan integrasi feathersjs dengan Vue

$ yarn add @feathersjs/feathers @feathersjs/socketio-client @feathersjs/authentication-client socket.io-client feathers-vuex

Initialisasi feathers client di dalam file src/api.js Integrasi feathers ke dalam local store Vue di file src/store.js

import Vue from 'vue'
import Vuex from 'vuex'
import feathersVuex from 'feathers-vuex'
import Api from './api'
const { service, auth, FeathersVuex } = feathersVuex(Api, { })
Vue.use(Vuex)
Vue.use(FeathersVuex)
export default new Vuex.Store({
state: {
},
mutations: {
},
actions: {
},
plugins: [
service('users'),
// Setup the auth plugin.
auth({ userService: 'users' })
]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment