first commit
This commit is contained in:
17
dist/esm/utils.js
vendored
Normal file
17
dist/esm/utils.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { ValidationError } from "./types/errors.js";
|
||||
export function toBlob(content) {
|
||||
if (content instanceof Blob)
|
||||
return content;
|
||||
return new Blob([content]);
|
||||
}
|
||||
export async function handleResponse(response) {
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => ({
|
||||
message: response.statusText,
|
||||
status: `${response.status}`,
|
||||
}));
|
||||
throw new ValidationError(errorData.message || "Unknown error", response.status);
|
||||
}
|
||||
const data = await response.json();
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user