api_interaction_services
v0.3.0
Published
All services use `fp-ts` library, http methods wrapper return `fp-ts` either. ## Simple api interaction class
Downloads
6
Readme
Api interaction services
All services use fp-ts
library, http methods wrapper return fp-ts
either.
Simple api interaction class
import { ApiInteractionService } from 'api_interaction_services';
So you can use it like this:
0.2x:
const fetcher = new ApiInteractionService("http://localhost:3300");
fetcher.get('/');
0.3x:
const fetcher = new ApiInteractionService("http://localhost:3300");
fetcher.get('/')();
Indendity interaction service
A more powerful tool that allows you to communicate with a closed API that requires access and refresh tokens.
import { BearerApiInteractionService } from 'api_interaction_services';
Inversify
Or you can use this classes with inverisify in a few steps:
- Declare SERVICE_IDENTIFIER name for service
export const SERVICE_IDENTIFIER = {
ApiInteractionService: Symbol.for("ApiInteractionService"),
};
- Bind this name to class with url to your API
container.bind<ApiInteractionService>(SERVICE_IDENTIFIER.ApiInteractionService).toConstantValue(new ApiInteractionService(API_URL));
- And now you can inject this service to your class
constructor(@inject(SERVICE_IDENTIFIER.ApiInteractionService) protected _apiService: ApiInteractionService) {}