Sunday, 16 April 2017

How to use pg-promise to download query as a CSV file?

db.any(query, [true])
.then(data => {
    //console.log("data: "+JSON.stringify(data));
    res.json(data);
    //res.send("data: "+JSON.stringify(data));
})
.catch(error => {console.log("ERROR:", error.message || error);});

Is it possible to get the data in a CSV format rather than JSON?



via Rohit Bandaru

No comments:

Post a Comment