Moved bot api files
This commit is contained in:
@@ -2,7 +2,7 @@ const serviceHost = process.env.SERVICE_HOST || 'http://localhost';
|
||||
const servicePort = process.env.SERVICE_PORT || 5000;
|
||||
const baseURL = `${serviceHost}:${servicePort}`;
|
||||
|
||||
export async function get(endpoint: string, params: Record<string, any> = {}): Promise<Response> {
|
||||
export async function getRequest(endpoint: string, params: Record<string, any> = {}): Promise<Response> {
|
||||
// Remove undefined params
|
||||
Object.keys(params).forEach((key) => params[key] === undefined && delete params[key]);
|
||||
const urlParams = new URLSearchParams(params);
|
||||
@@ -19,10 +19,10 @@ interface PostOptions {
|
||||
type?: 'json' | 'form';
|
||||
}
|
||||
|
||||
export async function post(endpoint: string, body: any, options?: PostOptions): Promise<Response> {
|
||||
export async function postRequest(endpoint: string, body?: any, options?: PostOptions): Promise<Response> {
|
||||
const url = `${baseURL}/${endpoint}`;
|
||||
let response;
|
||||
if (!options?.type || options.type === 'json') {
|
||||
if (body && (!options?.type || options.type === 'json')) {
|
||||
response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user