diff options
Diffstat (limited to 'src/store.js')
-rw-r--r-- | src/store.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/store.js b/src/store.js index 9080bd0..888add2 100644 --- a/src/store.js +++ b/src/store.js @@ -7,16 +7,24 @@ export default new Vuex.Store({ state: { api: process.env.VUE_APP_BACKEND_URL, commits: [], + emails: {}, }, get: { commits: state => { return state.commits }, + emails: state => { + return state.emails + }, }, mutations: { load_commits: (state, value) => { state.commits = value }, + load_emails: (state, value) => { + console.log(JSON.stringify(value)) + state.emails = value + }, }, actions: { // Get all commits from the api backend @@ -26,6 +34,20 @@ export default new Vuex.Store({ commit('load_commits', await response.json()); }) }, + // Get all emails and map them like an hash + async get_emails({commit}) { + await fetch(`${this.state.api}/email/`) + .then(async response => { + const emails_list = await response.json(); + const emails_obj = emails_list + .reduce((dict, elem) => { + dict[elem['email']] = elem['hash_md5'] + return dict; + }, {}) + + commit('load_emails', emails_obj); + }) + }, }, modules: { } |