Skip to content

Instantly share code, notes, and snippets.

@mtermoul
Created July 28, 2018 22:08
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 mtermoul/0c99ec595e3b937787f83d640f8eadfc to your computer and use it in GitHub Desktop.
Save mtermoul/0c99ec595e3b937787f83d640f8eadfc to your computer and use it in GitHub Desktop.
Fetching images from Cosmic JS and storing them back to vuex state.
...
action: {
...
fetchStoreCardImages ({commit}) {
// will get the images from Cosmic js media folder and store in vuex
const params = {
folder: 'store-card-images'
}
Cosmic.getMedia(params)
.then(data => {
commit('SET_STORE_CARD_IMAGES', data.media)
})
.catch(err => {
console.log(err)
})
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment