I have the following javascript:
#!/usr/bin/env node
var fs = require(’fs’);
var outfile = "hello.txt";
var out = "Modify this script to write out something different.\n";
fs.writeFileSync(outfile, out);
console.log("Script: " + __filename + "\nWrote: " + out + "To: " + outfile);
on executing the following commands:
node test.js
cat hello.txt
i get the following output:
[object Object]
What am i doing wrong?
Your getting an object returned as a string. Your going to need find out what properties the object has and return them, or loop through the object and show the properties, or convert it to a string...
console.log(JSON.stringify(objToJson));