xxxxxxxxxx
const jsonServer = require('json-server');
const server = jsonServer.create();
const router = jsonServer.router('db.json');
const middlewares = jsonServer.defaults();
server.use(middlewares);
server.use(router);
server.listen(3000, () => {
console.log('JSON Server is running');
});
xxxxxxxxxx
# Install JSON Server Globally
npm install -g json-server
# #Install JSON Server Locally
npm install json-server
# Check JSON Server version
json-server --version
# Run JSON server
json-server --watch db.json
# Change the server PORT
json-server --watch db.json --port 4000
xxxxxxxxxx
#Install JSON Server
npm install -g json-server
#Start JSON Server
json-server --watch db.json
xxxxxxxxxx
npm i --save-dev json-server
<add db.json file>
npx json-server --watch db.json
# to change port
npx json-server --watch db.json --port 8000
xxxxxxxxxx
npm install -g json-server
npm install json-server
json-server --watch db.json --port 3004
xxxxxxxxxx
{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
],
"profile": { "name": "typicode" }
}
xxxxxxxxxx
# Server portiga start berish...
npx json-server --watch db.json --port 8000
# JSON serverini globalini o'rnating.
npm install -g json-server
# JSON serverini mahalliy versiyasini o'rnating.
npm install json-server