From ba43c954fd2f34eff3d4f2e394899bb9d407fec8 Mon Sep 17 00:00:00 2001 From: Daryl Ronningen Date: Tue, 6 Jul 2021 14:58:29 -0500 Subject: [PATCH] fix: headers not working --- src/api/apiHandler.ts | 4 ++-- src/utils/types.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/apiHandler.ts b/src/api/apiHandler.ts index d678a24..9b08b10 100644 --- a/src/api/apiHandler.ts +++ b/src/api/apiHandler.ts @@ -25,7 +25,7 @@ export class ApiHandler { } public async makeRequest(options: IMakeRequestOptions): Promise { - const headers: Headers = new Headers(); + const headers: Map = new Map(); if (options.headers) for (const prop in options.headers) headers.set(prop, options.headers[prop]!); @@ -48,7 +48,7 @@ export class ApiHandler { try { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - const res = await fetch(`${this.baseApiUrl}${options.path}`, { method: options.method, headers, signal: controller.signal, body }); + const res = await fetch(`${this.baseApiUrl}${options.path}`, { method: options.method, headers: new Headers(headers), signal: controller.signal, body }); // TODO: handle Ratelimits diff --git a/src/utils/types.ts b/src/utils/types.ts index 5db5dd9..4d96ea1 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -22,7 +22,7 @@ export interface IMakeRequestOptions { body?: unknown; - headers?: Record; + headers?: Record; method: ApiMethods;