-
like use fetch in commonjs const fetch = (...args) =>
import('node-fetch').then(({ default: fetch }) => fetch(...args)); I try to use File in CommonJs const fetch = (...args) =>
import('node-fetch').then(({ default: fetch }) => fetch(...args));
const File = (...args) =>
import('node-fetch').then(({ File }) => File(...args));
function reqImage(url) {
return fetch(url)
.then((d) => d.buffer())
.then((b) => new File([b], 'abc.png'), { type: 'image/png' });
} and get error .then((b) => new File([b], 'abc.png'), { type: 'image/png' });
^
TypeError: File is not a constructor any one can help to know how to use File?馃槩 |
Beta Was this translation helpful? Give feedback.
Answered by
KairuiLiu
Mar 30, 2022
Replies: 1 comment
-
See Issue #1528 , Thanks a lot. it works very well |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
KairuiLiu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See Issue #1528 , Thanks a lot. it works very well