Skip to content

Instantly share code, notes, and snippets.

@nirazul
Created May 5, 2017 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nirazul/f9ce5be843a97f87dbc15621ebda2661 to your computer and use it in GitHub Desktop.
Save nirazul/f9ce5be843a97f87dbc15621ebda2661 to your computer and use it in GitHub Desktop.
blog.dreipol.ch - Snippet 9
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