I do not know what should be the problem but I currently implemented function that convert csv file to JSON and print result into console.log
function looks like :
var Converter = require("csvtojson").Converter;
var converter = new Converter({delimiter: ';'});
function convertToJSON() {
converter.fromFile('data.csv', function(err, result) {
if (err) {
console.log(err);
}
var data = result;
console.log(result);
});
}
and when I call it this way in server.js it return JSON to console
convertToJSON();
but when I would like to call this function from app.get by REST GET it return allways empty object.
app.get("convertToJSON", function(req,res){
convertToJSON();
})
I dont know what should be problem, why it is not work inside get call. There is no error during execution.
convertToJSON-Method doesn't return anything. It is just logging the object to console.convertToJSON(function(error, data) { res.send(data); })