Create a sample API for your projects due to your need easily.
First install the package globally:
npm i -g json-spot
Next, create db.json
in the root of your project containing API sample data:
{
"posts": [
{
"id": 1,
"title": "Title 1"
},
{
"id": 2,
"title": "Title 2"
},
...
]
}
A sample file is witihin samples/
folder.
Then, use json-spot
command for running the API:
json-spot --db <FILENAME> --port <PORT_NUMBER>
The default of <FILENAME>
and <PORT_NUMBER>
options are db.json
and 4000
. So if these values satisfy you, you can leave them blank.
Now, open your browser and enter the address below:
localhost:4000
Congratulation! Your API is ready!
json-spot
supports GET
, POST
, DELETE
and PUT
HTTP request methods for manipulating APIs you would create and run.