Skip to content Skip to sidebar Skip to footer

Use Json File As A Database For Javascript Web App

I was wondering if there is any way to use just a JSON file as a database to read and write straight to the file. I'm creating a quick Mockup web app that my company wants built bu

Solution 1:

If you want to write to it, No. If you're just using JavaScript in the browser then you can't write to files. You will need to have some API on the backend that you can send write requests to.

If you're just making a simple mockup that you intend to use for a quick presentation and nothing else, then you could consider using localStorage or sessionStorage in the browser to temporarily store data for a quick presentation.

Solution 2:

HTTP clients cannot write to arbitrary files on HTTP servers.

You need specially crafted requests (e.g. PUT) and server-side code which will recognise them and act on them.

If you are just creating a prototype, you'd probably want something like JSON Server

Post a Comment for "Use Json File As A Database For Javascript Web App"