Thursday, 16 March 2017

Node.js FS saving object

I have received this JSON form client API

{ COD: '100', ATD: '838', PAG: '246', VENC: '2017-01-27 00:00:00', }

I saved this JSON in var object, then I try save this variable object like this:

fs.writeFile("boleto.txt", object, 'utf8', function(err){
        if(err){
            console.log(err);
        } else {
            console.log("Log salvo");
        }
    });

But the result in BOLETO.TXT is this: [object Object]

And I need this:

COD: '100', ATD: '838', PAG: '246', VENC: '2017-01-27 00:00:00'

What I'm doing wrong?

ps.: When i call console.log(object) the log is correct.



via Diogo Barros

No comments:

Post a Comment