async calls are working, token is tested on app created (to do: add server call to verify token and role)

This commit is contained in:
Moriz Wahl 2021-10-27 15:54:20 +02:00
parent bdbfff76e3
commit 9b5d88a533
5 changed files with 23 additions and 2 deletions

View File

@ -33,6 +33,7 @@
"dotenv-webpack": "^7.0.3",
"graphql": "^15.6.1",
"jest": "26.6.3",
"regenerator-runtime": "^0.13.9",
"stats-webpack-plugin": "^0.7.0",
"vue": "^2.6.11",
"vue-apollo": "^3.0.8",

View File

@ -5,5 +5,15 @@
<script>
export default {
name: 'App',
methods: {
async readToken() {
if (window.localStorage && window.localStorage.vuex) {
this.$store.commit('token', JSON.parse(window.localStorage.vuex).token)
}
},
},
created() {
this.readToken()
},
}
</script>

View File

@ -1,6 +1,9 @@
import Vue from 'vue'
import App from './App.vue'
// without this async calls are not working
import 'regenerator-runtime'
import store from './store/store'
import router from './router/router'

View File

@ -3,9 +3,16 @@ import Vue from 'vue'
Vue.use(Vuex)
export const mutations = {
token: (state, token) => {
state.token = token
},
}
const store = new Vuex.Store({
mutations,
state: {
token: 'some-valid-token',
token: null,
},
})

View File

@ -10606,7 +10606,7 @@ regenerator-runtime@^0.11.0:
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==
regenerator-runtime@^0.13.4:
regenerator-runtime@^0.13.4, regenerator-runtime@^0.13.9:
version "0.13.9"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52"
integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==