Context
A feature that I would like to implement is to add a local(client side) database as offline feature for my cordova app using basic html, css, and js. It would be a fallback in case the internet connection is cut off. What I thought was that it would store the request url and request data inside a local JSON file and would have an option later on to be able to resend those failed request if the internet connection is restored.
Question
Is there a method to manipulate (add/create, edit/update, and delete) a JSON file stored inside a client app using pure JS?
What I've done so far is import and read a JSON file inside my app folder using the following code:
fetch("./database.json")
.then((response) => {
return response.json();
})
.then((data) => console.log(data));
(if there's a better way to do it, feel free to give a feedback in the comments)
That works fine and all, but I can't find any method on how to add/edit/delete an object and save the changes to that same JSON file.
According to this post which is half a decade ago, it is not possible without doing it in the backend.