Merge pull request #340 from automatisch/feature/basic-http-client
feat: Implement basic http client
This commit is contained in:
20
packages/backend/src/helpers/http-client/index.ts
Normal file
20
packages/backend/src/helpers/http-client/index.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
import { IJSONObject, IHttpClientParams } from '@automatisch/types';
|
||||
|
||||
export default class HttpClient {
|
||||
instance: AxiosInstance;
|
||||
|
||||
constructor(params: IHttpClientParams) {
|
||||
this.instance = axios.create({
|
||||
baseURL: params.baseURL,
|
||||
});
|
||||
}
|
||||
|
||||
async get(path: string, options?: IJSONObject) {
|
||||
return await this.instance.get(path, options);
|
||||
}
|
||||
|
||||
async post(path: string, body: IJSONObject | string, options?: IJSONObject) {
|
||||
return await this.instance.post(path, body, options);
|
||||
}
|
||||
}
|
4
packages/types/index.d.ts
vendored
4
packages/types/index.d.ts
vendored
@@ -175,3 +175,7 @@ export interface ISubstep {
|
||||
name: string;
|
||||
arguments: IField[];
|
||||
}
|
||||
|
||||
export type IHttpClientParams = {
|
||||
baseURL: string;
|
||||
}
|
||||
|
Reference in New Issue
Block a user