Skip to content

How to use File in CommonJS?馃槩 #1529

Answered by jimmywarting
KairuiLiu asked this question in Q&A
Discussion options

You must be logged in to vote

you could also ofc just do:

async function reqImage(url) {
  const { default: fetch, File } = await import('node-fetch')
  const res = await fetch(url)
  const blob = await res.blob()
  return new File([blob], 'abc.png'), { type: blob.type })
}

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by KairuiLiu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1528 on March 29, 2022 20:29.