UNPKG

smart-api-fetcher

Version:

A smart fetch utility with retries, timeout, and automatic JSON parsing.

14 lines (12 loc) 339 B
const smartFetch = require('./index.js'); (async () => { try { const data = await smartFetch('https://jsonplaceholder.typicode.com/posts/1', { retries: 2, timeout: 3000 }); console.log('Data fetched successfully:', data); } catch (err) { console.error('Fetch failed:', err.message); } })();