Created
July 19, 2018 14:26
-
-
Save sanath-kumar/174acf57d6efdf19d7dd2826cd0208fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Vue from 'vue' | |
| import Vuex from 'vuex' | |
| import Axios from 'axios' | |
| Vue.use(Vuex); | |
| export const store = new Vuex.Store({ | |
| state : { | |
| chats : null, | |
| handle : "" | |
| }, | |
| getters : { | |
| CHATS : state => { | |
| return state.chats | |
| }, | |
| HANDLE : state => { | |
| return state.handle | |
| } | |
| }, | |
| mutations : { | |
| SET_CHAT : (state,payload) => { | |
| state.chats = payload; | |
| }, | |
| ADD_CHAT : (state,payload) => { | |
| state.chats.push(payload); | |
| }, | |
| SET_HANDLE : (state,payload) => { | |
| state.handle = payload; | |
| } | |
| }, | |
| actions : { | |
| SET_CHAT : async (context,payload) => { | |
| let {data} = await Axios.get('http://localhost:5000/chat'); | |
| console.log(data); | |
| context.commit("SET_CHAT",data); | |
| }, | |
| ADD_CHAT : (context,payload)=> { | |
| context.commit("ADD_CHAT",payload); | |
| }, | |
| SET_HANDLE : (context,payload)=> { | |
| context.commit("SET_HANDLE",payload); | |
| } | |
| }, | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment