import {About_Plain} from "@/types/generated-strapi-interfaces/api/about"; import strapiClient from "@/api/strapi/strapi-client"; import qs from "qs"; import aboutQuery from "@/api/strapi/query/about.json"; import homeQuery from "@/api/strapi/query/home.json"; import servicesQuery from "@/api/strapi/query/services.json"; import {YogaBlogPost_Plain} from "@/types/generated-strapi-interfaces/api/yoga-blog-post"; import {Home_Plain} from "@/types/generated-strapi-interfaces/api/home"; import {ServicesPage_Plain} from "@/types/generated-strapi-interfaces/api/services-page"; class StrapiApi{ constructor( ) { } protected async getJson(path: string, params?: object){ const query = params ? qs.stringify(params,{ arrayFormat: 'indices' , encode: false}) : ""; const payload = await strapiClient.httpGetJson( path+ query ); return payload?.data; } public getImageUrl(imagePath: string){ return strapiClient.getImageUrl(imagePath); } public async getAboutPage(): Promise{ return this.getJson("/api/about?",aboutQuery); } public getHomePage(): Promise{ return this.getJson("/api/home?",homeQuery); } public getServicesPage(): Promise{ return this.getJson("/api/services-page?",servicesQuery); } public getBlog(blogId: string): Promise{ return this.getJson("/api/yoga-blog-posts/"+blogId,undefined); } } const api = new StrapiApi(); export default api;