Skip to content
Discussion options

You must be logged in to vote

Typically yes a custom Mutator: https://orval.dev/guides/custom-axios

for instance in my app once I login an get an API key or session ID my Mutator then adds this to every single call from Orval. I use Axios but fetch i believe has a similar mutator.

import Axios, { AxiosError, RawAxiosRequestConfig } from "axios";

export const AXIOS_INSTANCE = Axios.create({ baseURL: import.meta.env.REACT_APP_API_SERVER! });

export const useAxiosMutator = <T>(): ((config: RawAxiosRequestConfig) => Promise<T>) => {
	return (config: RawAxiosRequestConfig) => {
		const source = Axios.CancelToken.source();
		const promise = AXIOS_INSTANCE({
			...config,
			cancelToken: source.token,
		}).then(({ data }) => 

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@pbrzosko
Comment options

@vatte21
Comment options

@melloware
Comment options

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
question Further information is requested
3 participants