Skip to content

Commit

Permalink
fix: issues/49 'Reference error: window undefined' error in SSR compo…
Browse files Browse the repository at this point in the history
…nents
  • Loading branch information
ukalbhor committed Dec 14, 2022
1 parent f625bea commit 31db255
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ export type TransportOptions = {|

export type Transport = (TransportOptions) => ZalgoPromise<void>;

export function getHTTPTransport(
httpWin: CrossDomainWindowType = window
): Transport {
const win = isSameDomain(httpWin) ? assertSameDomain(httpWin) : window;

export function getHTTPTransport(httpWin?: CrossDomainWindowType): Transport {
return ({
url,
method,
Expand All @@ -33,6 +29,10 @@ export function getHTTPTransport(
enableSendBeacon = false,
}: TransportOptions): ZalgoPromise<void> => {
return ZalgoPromise.try(() => {
const httpWindow = httpWin ? httpWin : window;
const win = isSameDomain(httpWindow)
? assertSameDomain(httpWindow)
: window;
let beaconResult = false;

if (canUseSendBeacon({ headers, enableSendBeacon })) {
Expand Down

0 comments on commit 31db255

Please sign in to comment.