Files
Basalt2/node_modules/search-insights/lib/utils/getRequesterForBrowser.ts
Robert Jelic 31787b0e9b Fix
2025-02-16 18:04:24 +01:00

18 lines
512 B
TypeScript

import { supportsSendBeacon, supportsXMLHttpRequest } from "./featureDetection";
import type { RequestFnType } from "./request";
import { requestWithSendBeacon, requestWithXMLHttpRequest } from "./request";
export function getRequesterForBrowser(): RequestFnType {
if (supportsSendBeacon()) {
return requestWithSendBeacon;
}
if (supportsXMLHttpRequest()) {
return requestWithXMLHttpRequest;
}
throw new Error(
"Could not find a supported HTTP request client in this environment."
);
}