If you want to treat database.json like a real REST API, json-server is the standard choice.
Create a database.json with an initial structure: { "posts": [] } Use code with caution. Copied to clipboard database.json
You can now send a POST request to http://localhost:3000/posts using fetch in JavaScript: javascript If you want to treat database
In your terminal, run: npx json-server --watch database.json consider libraries like lowdb
: For larger projects, consider libraries like lowdb , which provide a safer API for interacting with local JSON files. typicode/lowdb: Simple and fast JSON database - GitHub
If you aren't using a server and just want to append data to the file locally using Node.js: javascript