Discussion on: How can I update a JSON file using fetch?

eruizdechavez profile image
Erick Ruiz de Chavez

TL;DR: You need some form of server side code to update the file.

First, you need to understand what you are doing. You have a client-server application, where the server is sending you that JSON file (wether it is a static file on a folder, or something more dynamic using PHP, Node, Python, etc.) and the client (your browser maybe?) is doing something with that JSON.

As you already noticed, whenever you change the JSON it is not persisted because it is just a copy on your browser, so, you need to ask the server to persist these changes.

This action (updating a file in a server) is a fairly simple operation, the difficult part is understanding (as @mxldevs briefly mentions) what you are doing and why.

We cannot just say use x.y to save the file if we do not even understand what you are doing and how.