UNPKG

tiny-essentials

Version:

Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.

24 lines 1.04 kB
/** * Performs a `fetch` request using any provided arguments and returns a Promise * that resolves with the parsed JSON response. * * This function acts as a wrapper around `fetch`, automatically parsing the * response body as JSON and handling errors both at the network level and * during JSON parsing. * * @function getJsonFetch * @param {...any} arguments - All arguments are forwarded directly to the `fetch` function. * Common usage is `getJsonFetch(url, options)`. * * @returns {Promise<any>} A Promise that resolves with the parsed JSON data * if the request succeeds and the response is valid JSON, * or rejects with an error if the request or parsing fails. * @deprecated * * @example * getJsonFetch('https://api.example.com/data') * .then(data => console.log(data)) * .catch(err => console.error('Fetch error:', err)); */ export default function getJsonFetch(...args: any[]): Promise<any>; //# sourceMappingURL=json.d.mts.map