shelving
Version:
Toolkit for using data in JavaScript.
14 lines (13 loc) • 520 B
JavaScript
/** Provider for API endpoints rooted at a common base URL. */
export class APIProvider {
/** Send a payload to an `Endpoint` and retrieve the result. */
async call(endpoint, payload, options, caller) {
const request = this.createRequest(endpoint, payload, options, caller);
const response = await this.fetch(request);
return this.parseResponse(endpoint, response, caller);
}
// Implement `AsyncDisposable`
async [Symbol.asyncDispose]() {
// Empty by default.
}
}