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
  • 5,448
  • 2
  • 39
  • 60
Marco
  • 1
  • 3

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,190
  • 3
  • 17
  • 47