UNPKG

@exromany/lido-csm-sdk

Version:

[![GitHub license](https://img.shields.io/github/license/lidofinance/lido-csm-sdk?color=limegreen)](https://github.com/lidofinance/lido-csm-sdk/blob/main/LICENSE.txt) [![Version npm](https://img.shields.io/npm/v/@lidofinance/lido-csm-sdk?label=version)](h

33 lines 858 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fetchWithFallback = exports.fetchJson = void 0; const fetchJson = async (url, params, parser) => { const response = await fetch(url, { method: 'GET', ...params, }); if (!response.ok) { return undefined; } if (parser) { const text = await response.text(); return parser(text); } return response.json(); }; exports.fetchJson = fetchJson; const fetchWithFallback = async (urls, fetcher) => { for (const url of urls) { if (!url) continue; try { const result = await fetcher(url); if (result) return result; } catch { } } }; exports.fetchWithFallback = fetchWithFallback; //# sourceMappingURL=fetch-json.js.map