Module can't use multiple objects

Viewed 22

I have a module created using module.exports and I can't use multiple javascript objects at my module

that's my "app.js" file:

const object2csv = require('./object2csv.js');
  object2csv(
      { id: 1 }, { id: 2 }, { id: 3 }
  )

and that's my "module.js" file:

module.exports = function (arr){
console.log(arr)
}

output:

{ id: 1 }

How can I use my all objects? Can I use forEach in modules? Please answer with examples I'm newbie.

1 Answers

you should send them as array

const object2csv = require('./object2csv.js');
object2csv([{ id: 1 }, { id: 2 }, { id: 3 }]);
Related