UNPKG

@planbgmbh/flinkey-web-components

Version:

This project provides some Web Components built for usage in combination with the flinkey API.

24 lines (23 loc) 564 B
/** * Sends an HTTP request via fetch API. * @param {Request} request - The HTTP request to send via fetch API. * @returns {Promise<HttpResponse<T>>} The HTTP response. * @template T */ async function http(request) { const response = await fetch(request); let parsedBody; try { if (response.status !== 204) { // This would may error if there is no body. parsedBody = await response.json(); } } catch (_a) { } if (!response.ok) { throw response; } response.parsedBody = parsedBody; return response; } export { http };