I have a basic axios client setup like this:
import axios from "axios";
const httpClient = axios.create({
baseURL: "https://localhost:7254/test",
});
httpClient.interceptors.request.use(
(config) => config,
(error) => Promise.reject(error)
);
httpClient.interceptors.response.use(
(response) => response,
(error) => Promise.reject(error)
);
export default httpClient;
In my service, I currently use it as follows:
export const myService = createService(base);
While this setup works fine, I now want to make the client dynamic so that it can accept any controller instead of being static with /test
and
"https://localhost:7254/test"
I would like to be able to do something like this in my services:
export const myService = createService(`{base}/test`);
Is there a way I can achieve this? Thank you.