fix loading feed

This commit is contained in:
john 2025-06-11 23:12:03 +02:00
parent cf5494c15b
commit 95ea2a5f23
4 changed files with 54 additions and 71 deletions

View file

@ -1,10 +1,8 @@
import { paths } from './schema.ts'
import createClient, { Client, Middleware } from 'openapi-fetch'
import createClient, { Middleware } from 'openapi-fetch'
import { dispatchMessage } from '../messageBus/messageBus.ts'
export type ApiClient = Client<paths>
export function initClient(): ApiClient {
export const initClient = () => {
const client = createClient<paths>({ baseUrl: import.meta.env.VITE_API_URL })
const UnauthorizedHandlerMiddleware: Middleware = {
async onResponse({ response }) {
@ -17,3 +15,5 @@ export function initClient(): ApiClient {
client.use(UnauthorizedHandlerMiddleware)
return client
}
export type ApiClient = ReturnType<typeof initClient>