I'm reading information from a api which returns text in JSON format. I want to take that text and write it to a file. When I do it writes it with a \ in front of everything looks like this .
[{ \"ElementA":\"ValueA" ... }] Here's what I've tried
var info = [] request('someApi', function(err, res, body) { if (err) { return console.log('Error:', err); } if (res.statusCode != 200) { return console.log('Invalid:' + res.statusCode); } info = JSON.stringify(body); fs.writeFile('public/file', info); }); Also the file that I'm trying to write to is .JS if that makes any difference. My desired output is :
[{ "ElementA": "Value A ...}]