/
githubmirror
/
amphtml
Обзор
Документация
Войти
/
githubmirror
/
amphtml
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/preact/utils/xhr.js
27 строк
636 B
Scott Rippey
✨ [Bento] Implement `bento-app-banner` (#37127)
28 янв 2022, 23:07
Не верифицирован
28 янв 2022, 23:07
95d5886
Код
Авторство
О чём код?
export const xhrUtils = { /** * Wrapper around `fetch` that returns the parsed JSON result * * @param {RequestInfo} url * @param {RequestInit} [init] * @return {Promise<*>} */ fetchJson(url, init) { return this.fetch(url, init).then((res) => res.json()); }, /** * Wrapper around `fetch` that checks the status code * * @param {RequestInfo} url * @param {RequestInit} [init] * @return {Promise<Response>} */ async fetch(url, init) { const response = await self.fetch(url, init); if (!response.ok) { throw new Error(response.statusText); } return response; }, };