L
L
lukka2020-05-15 14:12:51
Node.js
lukka, 2020-05-15 14:12:51

How to fix multiparty error?

Error when using multiparty

D:\node server template\node_modules\multiparty\index.js:81
  self.on('newListener', function(eventName) {
       ^

TypeError: self.on is not a function
    at Object.Form (D:\node server template\node_modules\multiparty\index.js:81:8)
    at Server.<anonymous> (D:\node server template\server.js:381:33)


Formdata is sent to the server with 2 files

Parser application code
const form = multiparty.Form()
        form.parse(req, function(err, fields, files) {
            if (!err) {
                console.log(fields)
            } else {
                console.log(err);
            }
        })


How to fix the error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2020-05-15
@lukka

Because new is forgotten
const form = new multiparty.Form();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question