node-csvtojson icon indicating copy to clipboard operation
node-csvtojson copied to clipboard

Async / await issue?

Open wwwork opened this issue 8 years ago • 2 comments

Trying to get converted to json string with node-csvtojson. Why node-csvtojson do not return converted to json string at async mode?

Code example

modeule.exports = async (req, res, next) => {
const strindWithDelimiter='bla;bla;bla'
const csv=require('csvtojson')
// Async / await usage
const jsonArray=await csv().fromString(strindWithDelimiter);
console.log( jsonArray); <--- receive empty object wtihs node-csvtojson custom options
}

wwwork avatar Jun 07 '18 12:06 wwwork

Hi, What version of csvtojson you are using? Also are you using es7 or typescript?

~Keyang

Keyang avatar Jun 07 '18 20:06 Keyang

es7, "csvtojson": "^1.1.9"

Yep! Thanks! I've been updated to lates version, and everything goes fine!

wwwork avatar Jun 08 '18 06:06 wwwork