Created
May 5, 2017 12:15
-
-
Save nirazul/f9ce5be843a97f87dbc15621ebda2661 to your computer and use it in GitHub Desktop.
blog.dreipol.ch - Snippet 9
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
function getRouteData({ commit, state, dispatch }, { url }) { | |
let FetchPromise = state.routes[url]; | |
if (FetchPromise) { | |
return FetchPromise; | |
} | |
return new Promise((resolve, reject) => { | |
Axios.request({ url }).then( | |
(request) => { | |
resolve(dispatch('setRouteData', { key: url, value: request.data })); | |
}, | |
(err) => { | |
reject(err); | |
} | |
); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment