const axios = require('axios');

// small fetch wrapper for external services (ViaCEP etc.) with basic rate-limiting
 async function fetchJson(url, opts = {}) {
   try {
     const r = await axios.get(url, { timeout: 10000, ...opts });
     return r.data;
   } catch (e) {
     console.warn(`fetchJson error ${url}: ${e.message}`);
     return null;
   }
 }

module.exports = { fetchJson };