UNPKG

node-consul-service

Version:

A robust Node.js service that integrates with HashiCorp Consul for service discovery and configuration management. This service provides a comprehensive solution for managing distributed systems and microservices architecture, making it easier to handle s

9 lines (8 loc) 370 B
import axios from 'axios'; import { getRandomServiceInstance } from './discovery'; export async function callService(serviceName, path = '/hello') { const instance = await getRandomServiceInstance(serviceName); const url = `http://${instance.ServiceAddress}:${instance.ServicePort}${path}`; const response = await axios.get(url); return response.data; }