JSFiddle - React, Tailwind, and code Playground
by oktaviardi pratama
JavaScript
############################# store/localStorage.js
export const state = () => ({
rewardInfo: {}
})
############################# store/index.js
export const getters = {
getRewardInfo(state) {
return state.localStorage.rewardInfo
}
}
export const mutations = {
setRewardInfo(state, value) {
state.localStorage.rewardInfo = value
}
}
############################### page atau component
import { mapGetters,mapMutations } from 'vuex'
export default {
data (){
return {
rewardInfo: {},
authorization: ''
}
},
computed: {
mapGetters(['getRewardInfo']),
authorization (){
let {authorization} = this.$store.getters.getRewardInfo
return authorization
}
},
moounted () {
this.rewardInfo = this.$store.getters.getRewardInfo
//this.rewardInfo.authorization
},
methods: {
saveReward() {
this.$store.commit('setRewardInfo', response)
}
}
}
response
{
my_custom_value: 0,
my_custom_value1: 0,
authorization: ‘’,
email: ‘’,
linkToken: ‘’,
verificationExpireTs: ‘’,
linking: ‘’,
isExistingUser: ‘’,
userParam: ‘’,
str_fullName: ‘’,
str_birthDate: ‘’,
str_gender: ‘’,
userAccessToken: ‘’,
linkSuccess: ‘’,
callbackUrlType: ‘’,
otp: ‘’,
infoSuccess: ‘’,
mdn: ‘’
}