feat: Implement basic http client

This commit is contained in:
Faruk AYDIN
2022-07-15 19:56:48 +03:00
parent e950d73742
commit 16e299a12d
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;
arguments: IField[];
}
export type IHttpClientParams = {
baseURL: string;
}