UNPKG

261 BJavaScriptView Raw
1/**
2 * Make it so that fetch throws on api errors.
3 */
4async function f(url, opts = {}) {
5 const res = await fetch(url, opts);
6 if (!res.ok) { throw new Error(res.statusText || res.message || res.msg || res); }
7 return await res.json();
8}
9
10export default f;