Files
vscode-codeql/extensions/ql-vscode/scripts/util/fetch.ts
2024-01-02 16:00:55 +01:00

11 lines
270 B
TypeScript

export async function fetchJson<T>(url: string): Promise<T> {
const response = await fetch(url);
if (!response.ok) {
throw new Error(
`Could not fetch ${url}: ${response.status} ${response.statusText}`,
);
}
return (await response.json()) as T;
}