diff --git a/src/gFetch.ts b/src/gFetch.ts index e4d40ff..89f5c50 100644 --- a/src/gFetch.ts +++ b/src/gFetch.ts @@ -84,6 +84,7 @@ type gFetchProperties = { export type GClientOptions = { path?: string; + headers?: { [key: string]?: string }; }; export type GReturn = { @@ -100,10 +101,12 @@ export type GFetchReturnWithErrors = Spread<[T, GFetchQueryDefault]>; export class GFetch extends Object { public path: string; + public headers?: { [key: string]: string } constructor(options: GClientOptions) { super(); - const { path } = options; + const { path, headers } = options; + this.headers = headers; this.path = path; this.fetch = this.fetch.bind(this); } @@ -127,7 +130,7 @@ export class GFetch extends Object { const res = await fetch(this.path, { method: "POST", credentials: "include", - headers: { "Content-Type": "application/json" }, + headers: { "Content-Type": "application/json", ...this.headers }, body: JSON.stringify(newQueries), });