@commercelayer/react-components
Version:
The Official Commerce Layer React Components
2 lines • 683 B
JavaScript
"use client";
;Object.defineProperty(exports,"__esModule",{value:!0}),exports.callExternalFunction=void 0;const tslib_1=require("tslib"),react_1=require("react"),callExternalFunction=_a=>tslib_1.__awaiter(void 0,[_a],void 0,function*({url,data}){const response=yield fetch(url,{method:"POST",body:JSON.stringify(data),headers:{"Content-Type":"application/json"}});if(!response.ok)throw new Error("Failed to call external function");return yield response.json()});exports.callExternalFunction=callExternalFunction;const ExternalFunctionContext=(0,react_1.createContext)({url:null,callExternalFunction:exports.callExternalFunction});exports.default=ExternalFunctionContext;