I am already fetching a hard-coded JSON file,
fetch("./dict.json")
.then(results => results.json())
.then(data => {
console.log(data);
})
But I would like to add to this already existing file, I have tried a few things such as
function setInfo(){
const new_data = [{
"email": document.getElementById("email").value,
"age": document.getElementById("age").value,
"name": document.getElementById("name").value,
"password": document.getElementById("password").value
}];
var blob = new Blob([stringify(new_data)], {
type: 'application/json'
});
var anchor = document.createElement('a')
anchor.download = "dict.json";
anchor.href = window.URL.createObjectURL(blob);
anchor.innerHTML = "download"
anchor.click();
}
But for me, this downloads a new JSON file called dict.json with the new information in it. Can I not reuse the same file?
Thank you!