-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Description
Hello. I understand that in order to use axios we have to modify the backendFetcher.ts file. But I do not want to miss anything and introduce a bug. Thus it would be great if there was an official guide to use axios with this awesome tool.
My attempt:
export async function backendFetch<
TData,
TError,
TBody extends {} | FormData | undefined | null,
THeaders extends {},
TQueryParams extends {},
TPathParams extends {},
>({
url,
method,
body,
headers,
pathParams,
queryParams,
signal,
}: BackendFetcherOptions<
TBody,
THeaders,
TQueryParams,
TPathParams
>): Promise<TData> {
// $axios is my axios instance with an interceptor
const response = await $axios({
url: `${baseUrl}${resolveUrl(url, queryParams, pathParams)}`,
method: method.toUpperCase(),
signal: signal,
data: body
? body instanceof FormData
? body
: JSON.stringify(body)
: undefined,
headers: { "Content-Type": "application/json", ...headers },
});
return response.data;
}Metadata
Metadata
Assignees
Labels
No labels