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

30 lines 717 B
export const fetchJson = async (url, params, parser) => { const response = await fetch(url, { method: 'GET', ...params, }); if (!response.ok) { // TODO: throw error ??? return undefined; } if (parser) { const text = await response.text(); return parser(text); } return response.json(); }; export const fetchWithFallback = async (urls, fetcher) => { for (const url of urls) { if (!url) continue; try { const result = await fetcher(url); if (result) return result; } catch { /* noop */ } } }; //# sourceMappingURL=fetch-json.js.map