-
|
Hi, I tried something like this: import type { paths } from '~/types/schema'
import createClient from 'openapi-fetch'
export function getApiClient() {
const sanctumClient = useSanctumClient()
return createClient<paths>({
baseUrl: 'http://localhost:8000/',
fetch: sanctumClient,
})
}Any ideas to make it work ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
|
Hey @npldevfr , I have never used this library but based on their docs, fetch replacement should work as expected. Can you provide more details on what's failing for you? |
Beta Was this translation helpful? Give feedback.
-
|
So @manchenkoff, I looked into this a bit deeper and here is what I found. The issue occurs because when we use: const sanctumClient = useSanctumClient()
const client = createClient<paths>({
baseUrl: "http://localhost:8000",
fetch: sanctumClient
})openapi-fetch tries to check the response headers: response.headers.get("Content-Length"). maybe that's why ! This is maybe not the good schema ? I got an error like : TypeError: Cannot read properties of undefined (reading 'get')
|
Beta Was this translation helpful? Give feedback.


i used
sanctumClient.nativeand this is working great 🎉, the .raw was returning the same error as above "Failed to execute 'json'..."The other approach I was considering is to move to the HeyApi client; they have an ofetch-based client: https://h…