Skip to content

Commit 75505cc

Browse files
committed
fix: throw error if URL is provided but fetch is not available
1 parent 40f8edd commit 75505cc

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

PDFMergerBase.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ export default class PDFMergerBase {
162162

163163
// see https://developer.mozilla.org/en-US/docs/Web/API/URL
164164
if (input instanceof URL) {
165+
if (typeof fetch === 'undefined') {
166+
throw new Error('fetch is not defined. You need to use a polyfill for this to work in Node.js.')
167+
}
165168
const res = await fetch(input)
166169
const aBuffer = await res.arrayBuffer()
167170
return new Uint8Array(aBuffer)

0 commit comments

Comments
 (0)