Answers for "how to collect multiple fields using busboy nodejs"

1

how to collect multiple fields using busboy nodejs

app.post('/somewhere', (req, res) => {

  let formData = new Map();
  req.busboy.on('field', function(fieldname, val) {
    formData.set(fieldname, val);
  });

  req.busboy.on("finish", function() {

    console.log(formData) // Map { 'name' => 'hi', 'number' => '4' }
    // here you can do 
    formData.get('name') //  'hi'
    formData.get('number') //  '4'

    // any other logic with formData here

    res.end()
  });
});
Posted by: Guest on July-01-2021

Code answers related to "how to collect multiple fields using busboy nodejs"

Code answers related to "Javascript"

Browse Popular Code Answers by Language