UNPKG

@stolostron/multicluster-sdk

Version:

Provides extensions and APIs that dynamic plugins can use to leverage multicluster capabilities provided by Red Hat Advanced Cluster Management.

23 lines 995 B
"use strict"; 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 () => { var _a; return (_a = controller.current) === null || _a === void 0 ? void 0 : _a.abort(); }; }, []); return (url) => { var _a; return (0, dynamic_plugin_sdk_1.consoleFetch)(url, { signal: (_a = controller.current) === null || _a === void 0 ? void 0 : _a.signal, method: 'GET', headers: { 'Content-Type': 'application/json' }, }).then((response) => response.json()); }; }; exports.useSafeFetch = useSafeFetch; //# sourceMappingURL=useSafeFetch.js.map