2020-08-20 02:10:42 +02:00
|
|
|
import { env } from '../env';
|
|
|
|
export async function fetchOrThrow(url, init) {
|
|
|
|
const fetch = env.getEnv().fetch;
|
2020-08-18 14:04:33 +02:00
|
|
|
const res = await fetch(url, init);
|
|
|
|
if (!(res.status < 400)) {
|
|
|
|
throw new Error(`failed to fetch: (${res.status}) ${res.statusText}, from url: ${res.url}`);
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
//# sourceMappingURL=fetchOrThrow.js.map
|