EX: const jsonData = [{ age: 12, name: 'Someone' }]; And i want convert jsonData to file JSON and use this file to send request to the S3 sever.
CodePudding user response:
I don't think you can do something like that, I believe writing to file using react is not quite straight forward refer: this
Refer node solution here
Well, what do you mean 'use this file to send request'? Do you want to store the created JSON file in S3? then pls do it in the backend.
CodePudding user response:
Ok... the S3 thing is a big complicated for such a short question, but in general you can do something like this...
fs.writeFile("../../pathToFile.json", yourJSON, 'utf8', (err) => {
if (err) {
console.log("Ahh mother****");
return console.log(err);
}
console.log("Now I have to send it to S3");
});