GuessNN/GuessNN-webapp/src/Utils.ts

9 lines
249 B
TypeScript

export function fetchJSON(url: string): Promise<unknown> {
return fetch(url)
.then((response) => {
if (!response.ok)
throw new Error(`Error fetching ${url}: ${response.status} - ${response.statusText}`);
return response.json();
});
}