@commercelayer/react-components
Version:
The Official Commerce Layer React Components
2 lines • 433 B
JavaScript
"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;