Skip to content
Discussion options

You must be logged in to vote

Orval does not currently generate a first-class createApiClient() object/factory in the shape from your example. The generated API surface is still operation functions/hooks.

The usual Orval way to solve the baseUrl / headers / auth-token part is a custom mutator (or, for fetch, baseUrl.runtime if all you need is runtime base URL resolution).

For axios, you can put the runtime configuration in your own axios instance/mutator:

// src/api/mutator/custom-instance.ts
import Axios, { AxiosRequestConfig } from 'axios';

export const api = Axios.create();

export const setApiClientConfig = (config: { baseURL?: string; token?: string }) => {
  api.defaults.baseURL = config.baseURL;
  api.defaults.h…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by melloware
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants