This is my function in my node JS script:
const uploadFile = async () => {
const buffer = fs.readFileSync('scripts/pose.png')
const formData = new FormData()
formData.append('file', buffer, 'dummyName.png')
const headers = {
Authorization: `Bearer ${jwt}`,
maxBodyLength: Infinity,
maxContentLength: Infinity,
}
const response = await axios.post(
`${process.env.URL}/v1/files`,
formData,
{
headers
},
)
return response
}
no matter what I’m doing it’s not working… with this code I’m getting an error:
"source.on is not a function"
Can someone help me, I tried literally everything!
2
Answers
I want to be sure i understand your question. but if what you are trying to do is upload an image from a form, you can use multer for it. it’s quite easy to use and understand.
check them on npmjs here: https://www.npmjs.com/package/multer