diff --git a/src/Options.ts b/src/Options.ts index 44293ad..352f7d7 100644 --- a/src/Options.ts +++ b/src/Options.ts @@ -17,6 +17,7 @@ interface Options { retryDelay?: number | ((err: NodeJS.ErrnoException | null, res: Response | void, attemptNumber: number) => number); socketTimeout?: number; timeout?: number; + withCredentials?: boolean; isMatch?: (requestHeaders: IncomingHttpHeaders, cachedResponse: CachedResponse, defaultValue: boolean) => boolean; isExpired?: (cachedResponse: CachedResponse, defaultValue: boolean) => boolean; diff --git a/src/browser.ts b/src/browser.ts index b0fbb04..5e7def3 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -108,6 +108,11 @@ function request(method: HttpVerb, url: string, options: Options): ResponsePromi reject(err); }; } + + if (options.withCredentials) { + xhr.withCredentials = options.withCredentials; + } + xhr.onreadystatechange = function () { if (xhr.readyState === 4) { var headers: {[key: string]: string} = {};