0

I'm trying to using Http for saving the value of a string in a local file. but it didn't work and I have not found information about how to do that operation. Thanks for helping me.

let mystring = "My string";
this.http.post('../../assets/tracing.config', mystring);
Iman Bahrampour
  • 6,180
  • 2
  • 41
  • 64
Marco
  • 11
  • 1
  • 4

1 Answers1

0

You can use this npm

npm install file-saver --save
import { saveAs } from 'file-saver';


obj = {
    ...
};


const blob = new Blob([JSON.stringify(obj)], {type : 'application/json'});
saveAs(blob, 'test.json');

If you want to save data using node.js

var fs = require('fs');
fs.writeFile("/fileName.json", myData, function(err) {
if(err) {
    return console.log(err);
}

console.log("The file was saved!");
}); 
Sachin Shah
  • 4,503
  • 3
  • 23
  • 50