Skip to content

Conversation

jdrouet
Copy link

@jdrouet jdrouet commented Oct 2, 2025

When using the axios client, I'd like to be able to provide an axios instance. The way to do in the doc is to define a global constant which is then used globally. This is a problem because it allows only a single instance of the client in the application and it's potentially prone to security issues.
With this, we can create an instance of axios an pass it as an argument like the following

const instance = axios.create({ headers: { Authentication: 'Bearer foo' } });
const api = createClient();

return api(instance);

Fix #653

@melloware melloware added axios Axios related issue tanstack-query TanStack Query related issue labels Oct 2, 2025
@melloware
Copy link
Collaborator

this looks pretty good to me build is running now

@melloware
Copy link
Collaborator

sorry do a git pull from main please

@jdrouet jdrouet force-pushed the jdrouet/axios-instance branch from 21687c4 to 4b4ccfa Compare October 2, 2025 16:53
@jdrouet
Copy link
Author

jdrouet commented Oct 2, 2025

I rebased 😉

@melloware
Copy link
Collaborator

running build again

@melloware
Copy link
Collaborator

ok it looks like it is failing the samples check you might want to run yarn update-samples then yarn test:samples

Signed-off-by: Jeremie Drouet <[email protected]>
@jdrouet
Copy link
Author

jdrouet commented Oct 2, 2025

@melloware should be fixed now 🤔

@melloware
Copy link
Collaborator

Parameter 'axios' cannot reference itself.

@jdrouet
Copy link
Author

jdrouet commented Oct 3, 2025

I will come with a proper fix today or tomorrow 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
axios Axios related issue tanstack-query TanStack Query related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass in custom axios instance
2 participants