Node route n graph file

Node route n graph file
0.0 0

app.get('/documents/:var', function(req, res,next) {
exporter.export(exportSettings, function (err, resd) {
    if(resd){var svg_to_png = require('svg-to-png');
    svg_to_png.convert(, imagedata) // async, returns promise
    .then( function(){fs.writeFile('logos.png', imagedata, 'binary', function(err){
            if (err) throw err
            console.log('File saved.')
        // Do tons of stuff
        var imagedata
        // var base64Data = imagedata.replace(/^data:image\/png;base64,/, "");

    //The export result is now in res.
    //If the output is not PDF or SVG, it will be base64 encoded (
    //If the output is a PDF or SVG, it will contain a filename (res.filename).

    //Kill the pool when we're done with it, and exit the application
    // exporter.killPool();
    // process.exit(1);
Im trying to build a route that writes graphs, into a file and send it to frontend
but i tried all day with different methods.
Anibody know this stuff?
I can console.log its an object { data: 'omfepf4294jr44'}
but when i try save it on server for testing the image is unreadable.