/**
 * Created by pomy on 11/5/16.
 */

import * as types from './mutation-types';

export const beforeGetResumeData = (store) => {
    let {state,commit,dispatch,rootState,getters} = store;
    commit(types.BEFORE_GET_RESUME_DATA);
};

export const getResumeData = ({commit,dispatch}) => {
    dispatch('beforeGetResumeData'); //same as commit(types.BEFORE_GET_RESUME_DATA)
    fetch('/resume').then((res)=>{
        return res.json();
    }).then((data)=>{
        commit({
            type:types.GET_RESUME_DATA,
            resume:data.resume
        });
    }).catch((err) => console.log('error',err));
};
@@ -371,16 +371,513 @@
 ATA)%0A   
+ let xhr = new XMLHttpRequest();%0A    xhr.onreadystatechange = () =%3E%7B%0A        if(xhr.readyState === 4)%7B%0A            if(xhr.status %3E= 200 && xhr.status %3C 300)%7B%0A                commit(%7B%0A                    type:types.GET_RESUME_DATA,%0A                    resume:JSON.parse(xhr.responseText).resume%0A                %7D);%0A            %7D else %7B%0A                console.log('request was unsuccessful:',xhr.status);%0A            %7D%0A        %7D%0A    %7D;%0A    xhr.open('GET','/resume',true);%0A    xhr.send(null);%0A    //
  fetch('
@@ -899,24 +899,27 @@
 (res)=%3E%7B%0A   
+ //
      return 
@@ -929,24 +929,27 @@
 .json();%0A   
+ //
  %7D).then((da
@@ -954,24 +954,27 @@
 data)=%3E%7B%0A   
+ //
      commit(
@@ -970,32 +970,35 @@
     commit(%7B%0A   
+ //
          type:ty
@@ -1013,32 +1013,35 @@
 RESUME_DATA,%0A   
+ //
          resume:
@@ -1051,24 +1051,27 @@
 a.resume%0A   
+ //
      %7D);%0A   
@@ -1070,16 +1070,19 @@
  %7D);%0A   
+ //
  %7D).catc

replace fetch with xhr