diff --git a/src/common/client.ts b/src/common/client.ts
index 3aec6f7..8a0aefd 100644
--- a/src/common/client.ts
+++ b/src/common/client.ts
@@ -31,7 +31,7 @@ export class Client {
const request = command.getRequest()
const authToken = await this.getAuthToken?.()
const response = await fetch(request.baseUrl + request.path, {
- method: "POST",
+ method: request.method,
headers: {
...request.headers,
...(authToken ? { Authorization: `Bearer ${authToken}` } : {}),
diff --git a/src/common/command.ts b/src/common/command.ts
index 5679e98..5f83d8c 100644
--- a/src/common/command.ts
+++ b/src/common/command.ts
@@ -19,6 +19,13 @@ export abstract class Command {
*/
protected abstract getBaseUrl(): string
+ /**
+ * Get the method for the request
+ */
+ protected getMethod(): string {
+ return "POST"
+ }
+
/**
* Get the path for the request
*/
@@ -29,17 +36,19 @@ export abstract class Command {
/**
* Get the body for the request
*/
- protected getBody(): string {
- return JSON.stringify(this.input)
+ protected getBody(): string | undefined {
+ return this.input ? JSON.stringify(this.input) : undefined
}
/**
* Get the headers for the request
*/
protected getHeaders(): Record {
- return {
- "Content-Type": "application/json",
- }
+ return this.getBody()
+ ? {
+ "Content-Type": "application/json",
+ }
+ : {}
}
/**
@@ -51,10 +60,11 @@ export abstract class Command {
* Get the request object
*/
public getRequest(): {
- body: string
+ body: string | undefined
headers: Record
baseUrl: string
path: string
+ method: string
parseResponse: (response: unknown) => Output
} {
return {
@@ -62,6 +72,7 @@ export abstract class Command {
headers: this.getHeaders(),
baseUrl: this.getBaseUrl(),
path: this.getPath(),
+ method: this.getMethod(),
parseResponse: this.parseResponse.bind(this),
}
}