2020-08-20 02:10:42 +02:00
|
|
|
import { bufferToImage } from './bufferToImage';
|
|
|
|
import { fetchOrThrow } from './fetchOrThrow';
|
|
|
|
export async function fetchImage(uri) {
|
|
|
|
const res = await fetchOrThrow(uri);
|
2020-08-18 14:04:33 +02:00
|
|
|
const blob = await (res).blob();
|
|
|
|
if (!blob.type.startsWith('image/')) {
|
|
|
|
throw new Error(`fetchImage - expected blob type to be of type image/*, instead have: ${blob.type}, for url: ${res.url}`);
|
|
|
|
}
|
2020-08-20 02:10:42 +02:00
|
|
|
return bufferToImage(blob);
|
2020-08-18 14:04:33 +02:00
|
|
|
}
|
|
|
|
//# sourceMappingURL=fetchImage.js.map
|