import { ActionContext } from 'vuex'; import { IContentfulState } from './state'; import { IState } from '../state'; import { HttpService } from '@/app/shared/services/HttpService/HttpService'; import { AxiosResponse, AxiosError } from 'axios'; export interface IContentfulResponse { count: number; } export interface IContentfulActions { getContent(context: ActionContext, params: { slug: string; locale: string }): Promise; } export const ContentfulActions: IContentfulActions = { getContent( { commit, state }: ActionContext, params: { slug: string; locale: string }, ): Promise { return HttpService.get('/cms', { params }) .then((res: AxiosResponse) => { commit('SET_PAGE', res.data); }) .catch((e: AxiosError) => { commit('SET_PAGE', null); throw e; }); }, };