fix WebRequest
All checks were successful
Publish Package / build (push) Successful in 17s

This commit is contained in:
Lee 2024-04-18 09:18:32 +01:00
parent a815112fb9
commit 7693e7055b

@ -16,6 +16,13 @@ export default class WebRequest {
}, },
}); });
// Resolve with a buffer if the content type is an image
if (response.headers.get("content-type")?.includes("image/")) {
const arrayBuffer = await response.arrayBuffer();
resolve(Buffer.from(arrayBuffer) as unknown as T);
return;
}
const data = await response.json(); const data = await response.json();
// Reject if the status code is not 200 // Reject if the status code is not 200