Closed DavidVaness closed 1 year ago
What about making a global function or utility class which follows same interface with IConnection
?
export function prepare(): api.IConnection;
export class MyConnection implements api.IConnection {
}
Sounds good to me, will have a look at this tomorrow. Ty
Okay, so I misunderstood your response.
This would still mean I have to add a connection to every request I have to make.
For sure we could abstract away the logic of setting up the connection like you showed above, but the argument has to get passed for every request.
My wish would be to something like this:
import api from '@myOrg/my-api';
export const instance = api.create({
connection: import.meta.env.VITE_BACKEND_URL
});
and every request has the connection already set up
import { instance } from './api';
const data = await instance.functional.domain.endpoint();
No plan to make the connection type to be such OOP styled.
My plan is to make IConnection to be a common interface for every SDK.
Question
Hey @samchon, thank you for this great library. We are just integrating it into our project and are wondering if there is a more ergonomic way to set up the baseUrl for the sdk client. We would like to set it up once and then change it depending on the environment.
maybe similar to the way axios does it?
Cheers David