@stolostron/multicluster-sdk
Version:
Provides extensions and APIs that dynamic plugins can use to leverage multicluster capabilities provided by Red Hat Advanced Cluster Management.
20 lines • 827 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.useSafeFetch = void 0;
/* Copyright Contributors to the Open Cluster Management project */
const dynamic_plugin_sdk_1 = require("@openshift-console/dynamic-plugin-sdk");
const react_1 = require("react");
const useSafeFetch = () => {
const controller = (0, react_1.useRef)();
(0, react_1.useEffect)(() => {
controller.current = new AbortController();
return () => controller.current?.abort();
}, []);
return (url) => (0, dynamic_plugin_sdk_1.consoleFetch)(url, {
signal: controller.current?.signal,
method: 'GET',
headers: { 'Content-Type': 'application/json' },
}).then((response) => response.json());
};
exports.useSafeFetch = useSafeFetch;
//# sourceMappingURL=useSafeFetch.js.map