From 7d3cd3c6feefb2b4058565fa4b93c354a8c0eb25 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Wed, 20 Sep 2023 17:10:09 +0200 Subject: [PATCH] wip: 2023-09-20T12:53:34+0200 (1695207214) --- package.json | 2 +- src/Reflect.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 709e469..4a647dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "reflect-client", - "version": "1.1.0-beta.0", + "version": "1.1.0-beta.1", "main": "build/Reflect.js", "type": "module", "exports": { diff --git a/src/Reflect.ts b/src/Reflect.ts index be45ac2..9677cde 100644 --- a/src/Reflect.ts +++ b/src/Reflect.ts @@ -1,5 +1,8 @@ import { Method } from "./Method.js"; +// Export Method as importable directly from the Reflect.js ESM +export { Method }; + // Connect to a Reflect API instance over HTTP export default class Client { private url: string; @@ -19,6 +22,11 @@ export default class Client { this.headers["Authentication"] = `Bearer ${key}`; } + // Get fully qualified URL to endpoint + private getEndpoint(endpoint: string): string { + return this.url + endpoint; + } + // Call a Reflect API endpoint with method and optional payload public async call(endpoint: string, method: Method, payload: any = null): Promise { const options: object = { @@ -32,6 +40,6 @@ export default class Client { } // Fetch and return Response object - return await fetch(endpoint, options); + return await fetch(this.getEndpoint(endpoint), options); } } \ No newline at end of file