Skip to content

Instantly share code, notes, and snippets.

@championswimmer
Created July 14, 2018 00:06
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 championswimmer/378ebfa813c772692cf5613ce0a24e68 to your computer and use it in GitHub Desktop.
Save championswimmer/378ebfa813c772692cf5613ce0a24e68 to your computer and use it in GitHub Desktop.
import {Module, VuexModule, MutationAction} from 'vuex-module-decorators'
import {ConferencesEntity, EventsEntity} from '@/models/definitions'
@Module
export default class HGAPIModule extends VuexModule {
conferences: Array<ConferencesEntity> = []
events: Array<EventsEntity> = []
// 'events' and 'conferences' are replaced by returned object
// whose shape must be `{events: {...}, conferences: {...} }`
@MutationAction({mutate: ['events', 'conferences']})
async fetchAll () {
const response: Response = await getJSON('https://hasgeek.github.io/events/api/events.json')
return response
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment