how to collect multiple fields using busboy nodejs

Solutions on MaxInterview for how to collect multiple fields using busboy nodejs by the best coders in the world

showing results for - "how to collect multiple fields using busboy nodejs"
Kevin
06 Jul 2017
1app.post('/somewhere', (req, res) => {
2
3  let formData = new Map();
4  req.busboy.on('field', function(fieldname, val) {
5    formData.set(fieldname, val);
6  });
7
8  req.busboy.on("finish", function() {
9
10    console.log(formData) // Map { 'name' => 'hi', 'number' => '4' }
11    // here you can do 
12    formData.get('name') //  'hi'
13    formData.get('number') //  '4'
14
15    // any other logic with formData here
16
17    res.end()
18  });
19});