UNPKG

@vladmandic/face-api

Version:

FaceAPI: AI-powered Face Detection & Rotation Tracking, Face Description & Recognition, Age & Gender & Emotion Prediction for Browser and NodeJS using TensorFlow/JS

15 lines (13 loc) 390 B
import { env } from '../env/index'; export async function fetchOrThrow( url: string, // eslint-disable-next-line no-undef init?: RequestInit, ): Promise<Response> { const { fetch } = env.getEnv(); 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; }