We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This example from https://ts-rest.com/docs/core/custom does not work.
Where do response.headers come from? also this.baseUrl
this.baseUrl
import { contract } from './some-contract'; import axios, { Method, AxiosError, AxiosResponse, isAxiosError } from 'axios'; const client = initClient(contract, { baseUrl: 'http://localhost:3333/api', baseHeaders: { 'Content-Type': 'application/json', }, api: async ({ path, method, headers, body }) => { const baseUrl = 'http://localhost:3333/api'; //baseUrl is not available as a param, yet try { const result = await axios.request({ method: method as Method, url: `${this.baseUrl}/${path}`, headers, data: body, }); return { status: result.status, body: result.data, headers: response.headers }; } catch (e: Error | AxiosError | any) { if (isAxiosError(e)) { const error = e as AxiosError; const response = error.response as AxiosResponse; return { status: response.status, body: response.data, headers: response.headers }; } throw e; } }, });
The text was updated successfully, but these errors were encountered:
No branches or pull requests
This example from https://ts-rest.com/docs/core/custom does not work.
Where do response.headers come from?
also
this.baseUrl
The text was updated successfully, but these errors were encountered: