JSON Server

1. Install json-server.
npm i json-server --save-dev
2. Create a db.json file

Push some mock data to it.

db.json
            {
  "users": [
    {
      "id": 1,
      "name": "John Doe",
      "password": "password123",
      "email": "john.doe@example.com",
      "address": "123 Main St, Springfield, IL",
      "products": [1, 2],
      "createdAt": "2023-05-15T10:30:00Z"
    },
    {
      "id": 2,
      "name": "Jane Smith",
      "password": "secret456",
      "email": "jane.smith@example.com",
      "address": "456 Oak Ave, Anytown, CA",
      "products": [3],
      "createdAt": "2023-06-20T15:45:00Z"
    }
  ],
  "products": [
    {
      "id": 1,
      "name": "Smartphone",
      "description": "A high-end smartphone with advanced features.",
      "price": 699.99,
      "stockNumber": 50,
      "seller": "John Doe",
      "createdAt": "2023-05-16T09:00:00Z"
    },
    {
      "id": 2,
      "name": "Laptop",
      "description": "Powerful laptop for work and entertainment.",
      "price": 1299.99,
      "stockNumber": 20,
      "seller": "John Doe",
      "createdAt": "2023-05-18T11:20:00Z"
    },
    {
      "id": 3,
      "name": "Smartwatch",
      "description": "Fitness tracker with heart rate monitor.",
      "price": 199.99,
      "stockNumber": 30,
      "seller": "Jane Smith",
      "createdAt": "2023-06-21T08:45:00Z"
    }
  ]
}

        
3. Start the server

specify a port if you want.

json-server --watch db.json --port 3001
4. Server will now run on localhost:3001

and you can access users/products on localhost:3001/users or localhost:3001/products

You can now send GET/POST/PUT/DELETE requests to these urls, without setting up a backend server.

If you POST/DELETE something, it'll show in db.json file.