Files
gremiumhub/legalconsenthub/app/composables/testing/useTestDataApi.ts

25 lines
908 B
TypeScript

import { TestDataApi, Configuration, type ApplicationFormDto } from '~~/.api-client'
import { cleanDoubleSlashes, withoutTrailingSlash } from 'ufo'
import { wrappedFetchWrap } from '~/utils/wrappedFetch'
export function useTestDataApi() {
const appBaseUrl = useRuntimeConfig().app.baseURL
const { serverApiBasePath, clientProxyBasePath } = useRuntimeConfig().public
const basePath = withoutTrailingSlash(
cleanDoubleSlashes(import.meta.client ? appBaseUrl + clientProxyBasePath : clientProxyBasePath + serverApiBasePath)
)
const testDataApiClient = new TestDataApi(
new Configuration({ basePath, fetchApi: wrappedFetchWrap(useRequestFetch()) })
)
async function createTestDataApplicationForm(organizationId: string): Promise<ApplicationFormDto> {
return testDataApiClient.createTestDataApplicationForm({ organizationId })
}
return {
createTestDataApplicationForm
}
}