Skip to content

Commit

Permalink
Allow partial requestinitopts
Browse files Browse the repository at this point in the history
  • Loading branch information
Thom van Kalkeren committed Jun 17, 2021
1 parent 6ae591b commit 2a6b0e6
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/processor/RequestInitGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@ export class RequestInitGenerator {
public readonly mode: "same-origin" | "navigate" | "no-cors" | "cors" | undefined;
public readonly xRequestedWith: string;

constructor(opts: RequestInitGeneratorOpts = {
credentials: "include",
csrfFieldName: "csrf-token",
mode: "same-origin",
xRequestedWith: "XMLHttpRequest",
}) {
constructor(opts: Partial<RequestInitGeneratorOpts> = {}) {
this.baseHeaders = opts.headers || {};
this.csrfFieldName = opts.csrfFieldName;
this.credentials = opts.credentials;
this.mode = opts.mode;
this.xRequestedWith = opts.xRequestedWith;
this.csrfFieldName = opts.csrfFieldName ?? "csrf-token";
this.credentials = opts.credentials ?? "include";
this.mode = opts.mode ?? "same-origin";
this.xRequestedWith = opts.xRequestedWith ?? "XMLHttpRequest";
}

public authenticityHeader(options = {}): Record<string, string> {
Expand Down

0 comments on commit 2a6b0e6

Please sign in to comment.