import axios from 'axios'

export async function sendToNode(targetNode: any, payload: any, nodeId: string) {
  const response = await axios.post(
    `http://${targetNode.ip_address}:${targetNode.port}/api/sync/receive`,
    payload,
    {
      headers: {
        'Authorization': `Bearer ${targetNode.api_key}`,
        'X-Node-Id': nodeId
      },
      timeout: 30000
    }
  )
  return response.data
}

