Merge pull request #340 from automatisch/feature/basic-http-client

feat: Implement basic http client
This commit is contained in:
Ömer Faruk Aydın
2022-07-15 19:59:03 +03:00
committed by GitHub
2 changed files with 24 additions and 0 deletions

View 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);
}
}

View File

@@ -175,3 +175,7 @@ export interface ISubstep {
name: string; name: string;
arguments: IField[]; arguments: IField[];
} }
export type IHttpClientParams = {
baseURL: string;
}