UNPKG

@commercelayer/react-components

Version:
2 lines 433 B
"use client"; import{createContext}from"react";export const callExternalFunction=async({url,data})=>{const response=await 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 await response.json()};const ExternalFunctionContext=createContext({url:null,callExternalFunction});export default ExternalFunctionContext;