Is it possible to write collected data from form to local JSON file with React? If yes can anyone give a good example, if no can you give a good alternative?
Thanks
Is it possible to write collected data from form to local JSON file with React? If yes can anyone give a good example, if no can you give a good alternative?
Thanks
If you always want to create a new file, one option is to make a downloadable link as shown below. You can even do it programatically
function App() {
const jsonData = { age: 12, name: "Someone" };
return (
<div className="App">
<a
href={
"data:text/json;charset=utf-8," +
encodeURIComponent(JSON.stringify(jsonData))
}
download="fileName.json"
>
Download JSON
</a>
</div>
);
}