APIAbstract & API
APIAbstract
ts
import { APIInterface } from "./interfaces/API.ts";
/** @classdesc Base API Abstract class. Custom implementations of an API service
* should extend this class.
*
* The exact implementation details, as well as additional public or private methods
* are fully customizable.
*
* */
export default abstract class APIAbstract implements APIInterface {
public abstract get<T>(url: string): Promise<T>;
public abstract post<T>(url: string, data: object): Promise<T>;
}API
Built-in extension of APIAbstract. A thin wrapper around fetch(). Offers two public methods:
get() method
- Signature:
get<T>(url: string): Promise<T>
Resolves to a promise of type <T> which are the results of calling url using GET.
post() method
- Signature:
post<T>(url: string, data: object): Promise<T>
Resolves to a promise of type <T> which are the results of calling url with data serialized as JSON, using POST.