/** * A basic api request service * * It will send basic http requests and returns raw results */ import { $Fetch, FetchOptions } from "ohmyfetch"; class ApiRequestService { private readonly fetch: $Fetch; public constructor(fetch: $Fetch) { this.fetch = fetch; } /** * Send a GET request * * @param url * @param query */ public async get( url: string, query: AssociativeArray | null = null ): Promise { return await this.request("GET", url, null, query); } protected async request( method: string, url: string, body: string | null = null, query: AssociativeArray | null = null ): Promise { const config: FetchOptions = { method }; if (query) { config.query = query; } // @ts-ignore return this.fetch(url, config); } } export default ApiRequestService;