node.js - How to store json.stringify response into a file? -


currently having problem node.js project doing right now, don't know how can store json.stringify response below code in file can access json data or there better way without storing in file.

here code:

var watson = require('watson-developer-cloud');  var personality_insights = watson.personality_insights({     username: '...',     password: '...',     version: 'v2' });  personality_insights.profile({     text: 'i write explain why i’ll holding album, 1989, new streaming service, apple music. feel deserves explanation because apple has been , continue 1 of best partners in selling music , creating ways me connect fans. respect company , ingenious minds have created legacy based on innovation , pushing right boundaries.i’m sure aware apple music offering free 3 month trial signs service. i’m not sure know apple music not paying writers, producers, or artists 3 months. find shocking, disappointing, , unlike historically progressive , generous company.this not me. thankfully on fifth album , can support myself, band, crew, , entire management team playing live shows. new artist or band has released first single , not paid success.',     language: 'en'  }, function (err, response) {         if (err) {             console.log('error:', err);         } else {             console.log( json.stringify(response, null, 2) );         }     }); }); 

i using watson developer cloud above in code.

something this?

var watson = require('watson-developer-cloud'); var fs = require('fs');  var personality_insights = watson.personality_insights({     username: '...',     password: '...',     version: 'v2' });  personality_insights.profile({     text: 'blah blah blah',     language: 'en'  }, function (err, response) {         if (err) {             console.log('error:', err);         } else {             fs.writefile(                 './file.json',                  json.stringify(response, null, 2),                  function(err){                     throw err;                 }             );         }     }); }); 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -